diff options
Diffstat (limited to 'jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst')
267 files changed, 0 insertions, 56799 deletions
diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/EditorMessages.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/EditorMessages.java deleted file mode 100644 index 0def0398e..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/EditorMessages.java +++ /dev/null @@ -1,1541 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui; - -import org.eclipse.osgi.util.NLS; - -/** - * Provides localized messages from EditorMessages.properties. - */ -public final class EditorMessages extends NLS { - - private static final String BUNDLE_NAME = "org.eclipse.jst.jsf.facesconfig.ui.EditorMessages"; - - private EditorMessages() { - // Do not instantiate - } - - static { - NLS.initializeMessages(BUNDLE_NAME, EditorMessages.class); - } - - public static String AddEditManagedPropertyDialog_Add; - - public static String AddEditManagedPropertyDialog_Edit; - - /** - * see EditorMessages.properties - */ - public static String FacesConfigEditor_ErrorHandlingUndoConflicts_DialogMessage; - - /** - * see EditorMessages.properties - */ - public static String FacesConfigEditor_ErrorHandlingUndoConflicts_DialogTitle; - - /** - * see EditorMessages.properties - */ - public static String FacesConfigEditor_WaitForLoad_EditorTabTitle; - - /** - * see EditorMessages.properties - */ - public static String UI_Button_Add; - - /** - * see EditorMessages.properties - */ - public static String UI_Button_Edit; - - /** - * see EditorMessages.properties - */ - public static String UI_Button_Remove; - - /** - * see EditorMessages.properties - */ - public static String UI_Button_Add_more; - - /** - * see EditorMessages.properties - */ - public static String UI_Button_Edit_more; - - /** - * see EditorMessages.properties - */ - public static String Remove_Title; - - /** - * see EditorMessages.properties - */ - public static String Remove_Msg; - - /** - * see EditorMessages.properties - */ - public static String FindType; - - /** - * see EditorMessages.properties - */ - public static String FindType_Filter; - - /** - * see EditorMessages.properties - */ - public static String FindType_Error_CannotFindType; - - /** - * see EditorMessages.properties - */ - public static String FacesConfigEditor_Introduction_TabName; - - /** - * see EditorMessages.properties - */ - public static String FacesConfigEditor_Overview_TabName; - - /** - * see EditorMessages.properties - */ - public static String FacesConfigEditor_Pageflow_TabName; - - /** - * see EditorMessages.properties - */ - public static String FacesConfigEditor_ManagedBeans_TabName; - - /** - * see EditorMessages.properties - */ - public static String FacesConfigEditor_Components_TabName; - - /** - * see EditorMessages.properties - */ - public static String FacesConfigEditor_Others_TabName; - - /** - * see EditorMessages.properties - */ - public static String FacesConfigEditor_Source_TabName; - - /** - * see EditorMessages.properties - */ - public static String editor_pageflow_page_intro_name; - - /** - * see EditorMessages.properties - */ - public static String editor_pageflow_page_intro_title; - - /** - * see EditorMessages.properties - */ - public static String editor_pageflow_page_intro_help_HelpContextID; - - /** - * see EditorMessages.properties - */ - public static String editor_pageflow_page_intro_help_HelpToolTip; - - /** - * see EditorMessages.properties - */ - public static String ManagedBeanPage_Title; - - /** - * see EditorMessages.properties - */ - public static String ManagedBeanMasterSection_Name; - - /** - * see EditorMessages.properties - */ - public static String ManagedBeanMasterSection_Description; - -// public static String ManagedBeanMasterSection_HelpContextID; -// -// public static String ManagedBeanMasterSection_HelpToolTip; - - /** - * see EditorMessages.properties - */ - public static String ManagedBeanGeneralSection_Name; - - /** - * see EditorMessages.properties - */ - public static String ManagedBeanGeneralSection_Desc; - -// public static String ManagedBeanGeneralSection_HelpContextID; -// -// public static String ManagedBeanGeneralSection_HelpToolTip; - - /** - * see EditorMessages.properties - */ - public static String ManagedBeanGeneralSection_ManagedBeanName; - - /** - * see EditorMessages.properties - */ - public static String ManagedBeanGeneralSection_ManagedBeanClass; - - /** - * see EditorMessages.properties - */ - public static String ManagedBeanGeneralSection_ManagedBeanScope; - - /** - * see EditorMessages.properties - */ - public static String InitializationSection_Name; - - /** - * see EditorMessages.properties - */ - public static String InitializationSection_Description; - -// public static String InitializationSection_HelpContextID; -// -// public static String InitializationSection_HelpToolTip; - - /** - * see EditorMessages.properties - */ - public static String ManagedBeanPropertyEditDialog_Title_NewPropertyEntry; - - /** - * see EditorMessages.properties - */ - public static String ManagedBeanPropertyEditDialog_Title_ExistingPropertyEntry; - - /** - * see EditorMessages.properties - */ - public static String ManagedBeanPropertyEditDialog_PropertyName; - - /** - * see EditorMessages.properties - */ - public static String ManagedBeanPropertyEditDialog_PropertyClass; - - /** - * see EditorMessages.properties - */ - public static String ManagedBeanPropertyEditDialog_PropertyClass_Browse; - - /** - * see EditorMessages.properties - */ - public static String ManagedBeanPropertyEditDialog_ValueType; - - /** - * see EditorMessages.properties - */ - public static String ManagedBeanProeprtyEditPage_Description; - - /** - * see EditorMessages.properties - */ - public static String ManagedBeanPropertyEditDialog_Value; - - /** - * see EditorMessages.properties - */ - public static String ManagedBeanPropertyEditWizard_Title; - - /** - * see EditorMessages.properties - */ - public static String ManagedBeanProeprtyEditPage_Title; - - /** - * see EditorMessages.properties - */ - public static String ManagedBeanPropertyEditDialog_Value_Change; - - /** - * see EditorMessages.properties - */ - public static String ManagedBeanPropertyEditDialog_FindType; - - /** - * see EditorMessages.properties - */ - public static String ManagedBeanPropertyEditDialog_FindType_Filter; - - /** - * see EditorMessages.properties - */ - public static String InitializationSection_ClassType; - - /** - * see EditorMessages.properties - */ - public static String InitializationSection_ClassType_General; - - /** - * see EditorMessages.properties - */ - public static String InitializationSection_ClassType_Map; - - /** - * see EditorMessages.properties - */ - public static String InitializationSection_ClassType_List; - - /** - * see EditorMessages.properties - */ - public static String InitializationSection_PropertyTable_Name; - - /** - * see EditorMessages.properties - */ - public static String InitializationSection_PropertyTable_Class; - - /** - * see EditorMessages.properties - */ - public static String InitializationSection_PropertyTable_Value; - - /** - * see EditorMessages.properties - */ - public static String InitializationSection_MapType_KeyClass; - - /** - * see EditorMessages.properties - */ - public static String InitializationSection_MapType_ValueClass; - - /** - * see EditorMessages.properties - */ - public static String InitializationSection_MapTable_Title; - - /** - * see EditorMessages.properties - */ - public static String InitializationSection_MapTable_Key; - - /** - * see EditorMessages.properties - */ - public static String InitializationSection_MapTable_Value; - - /** - * see EditorMessages.properties - */ - public static String InitializationSection_ListType_ValueClass; - - /** - * see EditorMessages.properties - */ - public static String InitializationSection_ListTable_Title; - - /** - * see EditorMessages.properties - */ - public static String InitializationSection_ListTable_Value; - - /** - * see EditorMessages.properties - */ - public static String ListEntriesEditPage_Title; - - /** - * see EditorMessages.properties - */ - public static String ListEntriesWizard_Title; - - /** - * see EditorMessages.properties - */ - public static String ListEntriesEditPage_Description; - - /** - * see EditorMessages.properties - */ - public static String OverviewPage_page_name; - - /** - * see EditorMessages.properties - */ - public static String OverviewPage_page_id; - - /** - * see EditorMessages.properties - */ - public static String OverviewPage_page_title; - - /** - * see EditorMessages.properties - */ - public static String OverviewPage_PageflowOverview_summary; - - /** - * see EditorMessages.properties - */ - public static String OverviewPage_EditorSection_name; - - /** - * see EditorMessages.properties - */ - public static String OverviewPage_EditorSection_description; - - /** - * see EditorMessages.properties - */ - public static String OverviewPage_EditorSection_noplugin; - - /** - * see EditorMessages.properties - */ - public static String OverviewPage_EditorSection_nooverview; - -// public static String OverviewPage_EditorSection_Help_HelpContextID; -// -// public static String OverviewPage_EditorSection_Help_HelpToolTip; - - /** - * see EditorMessages.properties - */ - public static String OverviewPage_GeneralSection_name; - - /** - * see EditorMessages.properties - */ - public static String OverviewPage_GeneralSection_description; - - /** - * see EditorMessages.properties - */ - public static String OverviewPage_GeneralSection_label_name; - - /** - * see EditorMessages.properties - */ - public static String OverviewPage_GeneralSection_label_version; - -// public static String OverviewPage_GeneralSection_Help_HelpContextID; -// -// public static String OverviewPage_GeneralSection_Help_HelpToolTip; - - /** - * see EditorMessages.properties - */ - public static String OverviewPage_NavigationSection_name; - - /** - * see EditorMessages.properties - */ - public static String OverviewPage_NavigationSection_description; - - /** - * see EditorMessages.properties - */ - public static String OverviewPage_NavigationSection_table_col1; - - /** - * see EditorMessages.properties - */ - public static String OverviewPage_NavigationSection_table_col2; - - /** - * see EditorMessages.properties - */ - public static String OverviewPage_NavigationSection_table_col3; - - /** - * see EditorMessages.properties - */ - public static String OverviewPage_NavigationSection_pageflowPageID; - -// public static String OverviewPage_NavigationSection_Help_HelpContextID; -// -// public static String OverviewPage_NavigationSection_Help_HelpToolTip; - - /** - * see EditorMessages.properties - */ - public static String OverviewPage_ManagedBeanSection_name; - - /** - * see EditorMessages.properties - */ - public static String OverviewPage_ManagedBeanSection_description; - - /** - * see EditorMessages.properties - */ - public static String OverviewPage_ManagedBeanSection_table_namecol; - - /** - * see EditorMessages.properties - */ - public static String OverviewPage_ManagedBeanSection_table_scopecol; - - /** - * see EditorMessages.properties - */ - public static String OverviewPage_ManagedBeanSection_table_classcol; - - /** - * see EditorMessages.properties - */ - public static String OverviewPage_ManagedBeanSection_managedbeanPageID; - -// public static String OverviewPage_ManagedBeanSection_Help_HelpContextID; -// -// public static String OverviewPage_ManagedBeanSection_Help_HelpToolTip; - - /** - * see EditorMessages.properties - */ - public static String OverviewPage_ComponentsSection_name; - - /** - * see EditorMessages.properties - */ - public static String OverviewPage_ComponentsSection_description; - - /** - * see EditorMessages.properties - */ - public static String OverviewPage_ComponentsSection_table_typecol; - - /** - * see EditorMessages.properties - */ - public static String OverviewPage_ComponentsSection_table_namecol; - - /** - * see EditorMessages.properties - */ - public static String OverviewPage_ComponentsSection_componentsPageID; - -// public static String OverviewPage_ComponentsSection_Help_HelpContextID; -// -// public static String OverviewPage_ComponentsSection_Help_HelpToolTip; - - /** - * see EditorMessages.properties - */ - public static String OverviewPage_OthersSection_name; - - /** - * see EditorMessages.properties - */ - public static String OverviewPage_OthersSection_description; - - /** - * see EditorMessages.properties - */ - public static String OverviewPage_OthersSection_table_typecol; - - /** - * see EditorMessages.properties - */ - public static String OverviewPage_OthersSection_table_namecol; - - /** - * see EditorMessages.properties - */ - public static String OverviewPage_OthersSection_table_valuecol; - - /** - * see EditorMessages.properties - */ - public static String OverviewPage_OthersSection_othersPageID; - -// public static String OverviewPage_OthersSection_Help_HelpContextID; -// -// public static String OverviewPage_OthersSection_Help_HelpToolTip; - - /** - * see EditorMessages.properties - */ - public static String ManagedBeanPropertyGroup_error_EmptyName; - - /** - * see EditorMessages.properties - */ - public static String ManagedBeanPropertyGroup_error_EmptyClass; - - /** - * see EditorMessages.properties - */ - public static String MapEntriesEditGroup_Edit; - - /** - * see EditorMessages.properties - */ - public static String MapEntriesEditPage_Title; - - /** - * see EditorMessages.properties - */ - public static String MapEntriesWizard_Title; - - /** - * see EditorMessages.properties - */ - public static String MapEntryEditGroup_Key; - - /** - * see EditorMessages.properties - */ - public static String MapEntryEditGroup_error_EmptyKey; - - /** - * see EditorMessages.properties - */ - public static String MapEntryEditGroup_error_DuplicateKey; - - /** - * see EditorMessages.properties - */ - public static String MapEntryEditPage_Title; - - /** - * see EditorMessages.properties - */ - public static String MapEntryEditWizard_Title; - - /** - * see EditorMessages.properties - */ - public static String MapEntriesEditPage_Description; - - /** - * see EditorMessages.properties - */ - public static String MapEntryEditPage_Description; - - /** - * see EditorMessages.properties - */ - public static String ValueEditDialog_Title; - - /** - * see EditorMessages.properties - */ - public static String ValueEditWizard_Title; - - /** - * see EditorMessages.properties - */ - public static String ValueEditPage_Description; - - /** - * see EditorMessages.properties - */ - public static String ValueEditGroup_Value; - - /** - * see EditorMessages.properties - */ - public static String ValueEditPage_Title; - - /** - * see EditorMessages.properties - */ - public static String ComponentsPage_Title; - - /** - * see EditorMessages.properties - */ - public static String ComponentMasterSection_Name; - - /** - * see EditorMessages.properties - */ - public static String ComponentMasterSection_Description; - -// public static String ComponentMasterSection_HelpContextID; -// -// public static String ComponentMasterSection_HelpToolTip; - - /** - * see EditorMessages.properties - */ - public static String ComponentGeneralSection_Name; - - /** - * see EditorMessages.properties - */ - public static String ComponentGeneralSection_Description; - -// public static String ComponentGeneralSection_HelpContextID; -// -// public static String ComponentGeneralSection_HelpToolTip; - - /** - * see EditorMessages.properties - */ - public static String ComponentGeneralSection_Label_DisplayName; - - /** - * see EditorMessages.properties - */ - public static String ComponentGeneralSection_Label_Description; - - /** - * see EditorMessages.properties - */ - public static String ComponentGeneralSection_Label_ComponentType; - - /** - * see EditorMessages.properties - */ - public static String ComponentGeneralSection_Label_ComponentClass; - - /** - * see EditorMessages.properties - */ - public static String RenderKitMasterSection_Name; - - /** - * see EditorMessages.properties - */ - public static String RenderKitMasterSection_Description; - -// public static String RenderKitMasterSection_HelpContextID; -// -// public static String RenderKitMasterSection_HelpToolTip; - - /** - * see EditorMessages.properties - */ - public static String RenderKitGeneralSection_Name; - - /** - * see EditorMessages.properties - */ - public static String RenderKitGeneralSection_Description; - -// public static String RenderKitGeneralSection_HelpContextID; -// -// public static String RenderKitGeneralSection_HelpToolTip; - - /** - * see EditorMessages.properties - */ - public static String RenderKitGeneralSection_Label_DisplayName; - - /** - * see EditorMessages.properties - */ - public static String RenderKitGeneralSection_Label_Description; - - /** - * see EditorMessages.properties - */ - public static String RenderKitGeneralSection_Label_RenderKitID; - - /** - * see EditorMessages.properties - */ - public static String RenderKitGeneralSection_Label_RenderKitClass; - - /** - * see EditorMessages.properties - */ - public static String RendererSection_Name; - - /** - * see EditorMessages.properties - */ - public static String RendererSection_Description; - -// public static String RendererSection_HelpContextID; -// -// public static String RendererSection_HelpToolTip; - - /** - * see EditorMessages.properties - */ - public static String RendererSection_Table_NameColumn; - - /** - * see EditorMessages.properties - */ - public static String RendererSection_Table_ComponentFamilyColumn; - - /** - * see EditorMessages.properties - */ - public static String RendererSection_Table_TypeColumn; - - /** - * see EditorMessages.properties - */ - public static String RendererSection_Table_ClassColumn; - - /** - * see EditorMessages.properties - */ - public static String RendererSection_Dialog_Title_Add; - - /** - * see EditorMessages.properties - */ - public static String RendererSection_Dialog_Title_Edit; - - /** - * see EditorMessages.properties - */ - public static String RendererSection_Dialog_Tab_General; - - /** - * see EditorMessages.properties - */ - public static String RendererSection_Dialog_DisplayName; - - /** - * see EditorMessages.properties - */ - public static String RendererSection_Dialog_ComponentFamilyValue; - - /** - * see EditorMessages.properties - */ - public static String RendererSection_Dialog_TypeValue; - - /** - * see EditorMessages.properties - */ - public static String RendererSection_Dialog_RendererClass; - - /** - * see EditorMessages.properties - */ - public static String RendererSection_Dialog_Error_ComponentFamilyEmpty; - - /** - * see EditorMessages.properties - */ - public static String RendererSection_Dialog_Error_RendererTypeEmpty; - - /** - * see EditorMessages.properties - */ - public static String RendererSection_Dialog_Error_RendererClassEmpty; - - /** - * see EditorMessages.properties - */ - public static String RendererSection_Dialog_SelectComponentFamilyDialog_Title; - - /** - * see EditorMessages.properties - */ - public static String RendererSection_Dialog_ComponentFamilyCaption; - - /** - * see EditorMessages.properties - */ - public static String RendererSection_Dialog_ComponentFamilyLabel; - - /** - * see EditorMessages.properties - */ - public static String ConverterMasterSection_Name; - - /** - * see EditorMessages.properties - */ - public static String ConverterMasterSection_Description; - -// public static String ConverterMasterSection_HelpContextID; -// -// public static String ConverterMasterSection_HelpToolTip; - - /** - * see EditorMessages.properties - */ - public static String ConverterGeneralSection_Name; - - /** - * see EditorMessages.properties - */ - public static String ConverterGeneralSection_Description; - -// public static String ConverterGeneralSection_HelpContextID; -// -// public static String ConverterGeneralSection_HelpToolTip; - - /** - * see EditorMessages.properties - */ - public static String ConverterGeneralSection_Label_DisplayName; - - /** - * see EditorMessages.properties - */ - public static String ConverterGeneralSection_Label_Description; - - /** - * see EditorMessages.properties - */ - public static String ConverterGeneralSection_Label_ConverterID; - - /** - * see EditorMessages.properties - */ - public static String ConverterGeneralSection_Label_ConverterForClass; - - /** - * see EditorMessages.properties - */ - public static String ConverterGeneralSection_Label_ConverterClass; - - /** - * see EditorMessages.properties - */ - public static String ValidatorMasterSection_Name; - - /** - * see EditorMessages.properties - */ - public static String ValidatorMasterSection_Description; - -// public static String ValidatorMasterSection_HelpContextID; -// -// public static String ValidatorMasterSection_HelpToolTip; - - /** - * see EditorMessages.properties - */ - public static String ValidatorGeneralSection_Name; - - /** - * see EditorMessages.properties - */ - public static String ValidatorGeneralSection_Description; - -// public static String ValidatorGeneralSection_HelpContextID; -// -// public static String ValidatorGeneralSection_HelpToolTip; - - /** - * see EditorMessages.properties - */ - public static String ValidatorGeneralSection_Label_DisplayName; - - /** - * see EditorMessages.properties - */ - public static String ValidatorGeneralSection_Label_Description; - - /** - * see EditorMessages.properties - */ - public static String ValidatorGeneralSection_Label_ValidatorID; - - /** - * see EditorMessages.properties - */ - public static String ValidatorGeneralSection_Label_ValidatorClass; - - /** - * see EditorMessages.properties - */ - public static String AttributeSection_Name; - - /** - * see EditorMessages.properties - */ - public static String AttributeSection_Description; - -// public static String AttributeSection_HelpContextID; -// -// public static String AttributeSection_HelpToolTip; - - /** - * see EditorMessages.properties - */ - public static String AttributeSection_Table_NameColumn; - - /** - * see EditorMessages.properties - */ - public static String AttributeSection_Table_ClassColumn; - - /** - * see EditorMessages.properties - */ - public static String AttributeSection_Table_DefaultValueColumn; - - /** - * see EditorMessages.properties - */ - public static String AttributeSection_Table_SuggestedValueColumn; - - /** - * see EditorMessages.properties - */ - public static String AttributeSection_Dialog_Title_Add; - - /** - * see EditorMessages.properties - */ - public static String AttributeSection_Dialog_Title_Edit; - - /** - * see EditorMessages.properties - */ - public static String AttributeSection_Dialog_Tab_General; - - /** - * see EditorMessages.properties - */ - public static String AttributeSection_Dialog_AttributeName; - - /** - * see EditorMessages.properties - */ - public static String AttributeSection_Dialog_AttributeClass; - - /** - * see EditorMessages.properties - */ - public static String AttributeSection_Dialog_DefaultValue; - - /** - * see EditorMessages.properties - */ - public static String AttributeSection_Dialog_SuggestedValue; - - /** - * see EditorMessages.properties - */ - public static String AttributeSection_Dialog_Error_NameEmpty; - - /** - * see EditorMessages.properties - */ - public static String AttributeSection_Dialog_Error_ClassEmpty; - - /** - * see EditorMessages.properties - */ - public static String PropertySection_Name; - - /** - * see EditorMessages.properties - */ - public static String PropertySection_Description; - -// public static String PropertySection_HelpContextID; -// -// public static String PropertySection_HelpToolTip; - - /** - * see EditorMessages.properties - */ - public static String PropertySection_Table_NameColumn; - - /** - * see EditorMessages.properties - */ - public static String PropertySection_Table_ClassColumn; - - /** - * see EditorMessages.properties - */ - public static String PropertySection_Table_DefaultValueColumn; - - /** - * see EditorMessages.properties - */ - public static String PropertySection_Table_SuggestedValueColumn; - - /** - * see EditorMessages.properties - */ - public static String PropertySection_Dialog_Title_Add; - - /** - * see EditorMessages.properties - */ - public static String PropertySection_Dialog_Title_Edit; - - /** - * see EditorMessages.properties - */ - public static String PropertySection_Dialog_Tab_General; - - /** - * see EditorMessages.properties - */ - public static String PropertySection_Dialog_PropertyName; - - /** - * see EditorMessages.properties - */ - public static String PropertySection_Dialog_PropertyClass; - - /** - * see EditorMessages.properties - */ - public static String PropertySection_Dialog_DefaultValue; - - /** - * see EditorMessages.properties - */ - public static String PropertySection_Dialog_SuggestedValue; - - /** - * see EditorMessages.properties - */ - public static String PropertySection_Dialog_Error_NameEmpty; - - /** - * see EditorMessages.properties - */ - public static String PropertySection_Dialog_Error_ClassEmpty; - - /** - * see EditorMessages.properties - */ - public static String FacetSection_Name; - - /** - * see EditorMessages.properties - */ - public static String FacetSection_Description; - -// public static String FacetSection_HelpContextID; -// -// public static String FacetsSection_HelpToolTip; - - /** - * see EditorMessages.properties - */ - public static String FacetSection_Table_DisplayNameColumn; - - /** - * see EditorMessages.properties - */ - public static String FacetSection_Table_FacetNameColumn; - - /** - * see EditorMessages.properties - */ - public static String FacetSection_Table_DescriptionColumn; - - /** - * see EditorMessages.properties - */ - public static String FacetSection_Dialog_Title_Add; - - /** - * see EditorMessages.properties - */ - public static String FacetSection_Dialog_Title_Edit; - - /** - * see EditorMessages.properties - */ - public static String FacetSection_Dialog_Tab_General; - - /** - * see EditorMessages.properties - */ - public static String FacetSection_Dialog_FacetName; - - /** - * see EditorMessages.properties - */ - public static String FacetSection_Dialog_DisplayName; - - /** - * see EditorMessages.properties - */ - public static String FacetSection_Dialog_Description; - - /** - * see EditorMessages.properties - */ - public static String FacetSection_Dialog_Error_NameEmpty; - - /** - * see EditorMessages.properties - */ - public static String OthersPage_Title; - - /** - * see EditorMessages.properties - */ - public static String ActionListenerSection_Name; - - /** - * see EditorMessages.properties - */ - public static String ActionListenerSection_Description; - -// public static String ActionListenerSection_HelpContextID; -// -// public static String ActionListenerSection_HelpToolTip; - - /** - * see EditorMessages.properties - */ - public static String MessageBundleSection_Name; - - /** - * see EditorMessages.properties - */ - public static String MessageBundleSection_Description; - -// public static String MessageBundleSection_HelpContextID; -// -// public static String MessageBundleSection_HelpToolTip; - - /** - * see EditorMessages.properties - */ - public static String MessageBundleSection_Dialog_Title; - - /** - * see EditorMessages.properties - */ - public static String MessageBundleSection_Dialog_Message_SelectPropertyFile; - - /** - * see EditorMessages.properties - */ - public static String MessageBundleSection_Dialog_Message_AlreadyExists; - - /** - * see EditorMessages.properties - */ - public static String LocaleConfigSection_Name; - - /** - * see EditorMessages.properties - */ - public static String LocaleConfigSection_Description; - -// public static String LocaleConfigSection_HelpContextID; -// -// public static String LocaleConfigSection_HelpToolTip; - - /** - * see EditorMessages.properties - */ - public static String LocaleConfigSection_Wizard_WindowTitle; - - /** - * see EditorMessages.properties - */ - public static String LocaleConfigSection_Wizard_Page_Name; - - /** - * see EditorMessages.properties - */ - public static String LocaleConfigSection_Wizard_Page_Title; - - /** - * see EditorMessages.properties - */ - public static String LocaleConfigSection_Wizard_Page_Description; - - /** - * see EditorMessages.properties - */ - public static String LocaleConfigSection_Wizard_Page_LabelText; - - /** - * see EditorMessages.properties - */ - public static String LocaleConfigSection_Wizard_Page_AlreadyExistsError; - - /** - * see EditorMessages.properties - */ - public static String DefaultRenderKitIDSection_Name; - - /** - * see EditorMessages.properties - */ - public static String DefaultRenderKitIDSection_Description; - -// public static String DefaultRenderKitIDSection_HelpContextID; -// -// public static String DefaultRenderKitIDSection_HelpToolTip; - - /** - * see EditorMessages.properties - */ - public static String DefaultRenderKitIDSection_Wizard_WindowTitle; - - /** - * see EditorMessages.properties - */ - public static String DefaultRenderKitIDSection_Wizard_Page_Name; - - /** - * see EditorMessages.properties - */ - public static String DefaultRenderKitIDSection_Wizard_Page_Title; - - /** - * see EditorMessages.properties - */ - public static String DefaultRenderKitIDSection_Wizard_Page_Description; - - /** - * see EditorMessages.properties - */ - public static String DefaultRenderKitIDSection_Wizard_Page_LabelText; - - /** - * see EditorMessages.properties - */ - public static String DefaultRenderKitIDSection_Wizard_Page_AlreadyExistsError; - - /** - * see EditorMessages.properties - */ - public static String NavigationHandlerSection_Name; - - /** - * see EditorMessages.properties - */ - public static String NavigationHandlerSection_Description; - -// public static String NavigationHandlerSection_HelpContextID; -// -// public static String NavigationHandlerSection_HelpToolTip; - - /** - * see EditorMessages.properties - */ - public static String ViewHandlerSection_Name; - - /** - * see EditorMessages.properties - */ - public static String ViewHandlerSection_Description; - -// public static String ViewHandlerSection_HelpContextID; -// -// public static String ViewHandlerSection_HelpToolTip; - - /** - * see EditorMessages.properties - */ - public static String StateManagerSection_Name; - - /** - * see EditorMessages.properties - */ - public static String StateManagerSection_Description; - -// public static String StateManagerSection_HelpContextID; -// -// public static String StateManagerSection_HelpToolTip; - - /** - * see EditorMessages.properties - */ - public static String PropertyResolverSection_Name; - - /** - * see EditorMessages.properties - */ - public static String PropertyResolverSection_Description; - -// public static String PropertyResolverSection_HelpContextID; -// -// public static String PropertyResolverSection_HelpToolTip; - - /** - * see EditorMessages.properties - */ - public static String VariableResolverSection_Name; - - /** - * see EditorMessages.properties - */ - public static String VariableResolverSection_Description; - -// public static String VariableResolverSection_HelpContextID; -// -// public static String VariableResolverSection_HelpToolTip; - - /** - * see EditorMessages.properties - */ - public static String ApplicationFactorySection_Name; - - /** - * see EditorMessages.properties - */ - public static String ApplicationFactorySection_Description; - -// public static String ApplicationFactorySection_HelpContextID; -// -// public static String ApplicationFactorySection_HelpToolTip; - - /** - * see EditorMessages.properties - */ - public static String FacesContextFactorySection_Name; - - /** - * see EditorMessages.properties - */ - public static String FacesContextFactorySection_Description; - -// public static String FacesContextFactorySection_HelpContextID; -// -// public static String FacesContextFactorySection_HelpToolTip; - - /** - * see EditorMessages.properties - */ - public static String LifecycleFactorySection_Name; - - /** - * see EditorMessages.properties - */ - public static String LifecycleFactorySection_Description; - -// public static String LifecycleFactorySection_HelpContextID; -// -// public static String LifecycleFactorySection_HelpToolTip; - - /** - * see EditorMessages.properties - */ - public static String RenderKitFactorySection_Name; - - /** - * see EditorMessages.properties - */ - public static String RenderKitFactorySection_Description; - -// public static String RenderKitFactorySection_HelpContextID; -// -// public static String RenderKitFactorySection_HelpToolTip; - - /** - * see EditorMessages.properties - */ - public static String PhaseListenerSection_Name; - - /** - * see EditorMessages.properties - */ - public static String PhaseListenerSection_Description; - -// public static String PhaseListenerSection_HelpContextID; -// -// public static String PhaseListenerSection_HelpToolTip; - - /** - * see EditorMessages.properties - */ - public static String MultiPageEditorOutlinePage_noOutline; - - /** - * see EditorMessages.properties - */ - public static String FacesConfigEditor_Error_OpenModel_Title; - - /** - * see EditorMessages.properties - */ - public static String FacesConfigEditor_Error_OpenModel; - - /** - * see EditorMessages.properties - */ - public static String FacesConfigEditor_WaitForLoadPage_Title; - - /** - * see EditorMessages.properties - */ - public static String ModelLoader_LoadingModelJobName; - - /** - * Align bottom action label. - */ - public static String AlignmentAction_AlignBottomAction_Label; - - /** - * Align bottom action tooltip. - */ - public static String AlignmentAction_AlignBottomAction_Tooltip; - - /** - * Align center action label. - */ - public static String AlignmentAction_AlignCenterAction_Label; - - /** - * Align center action tooltip. - */ - public static String AlignmentAction_AlignCenterAction_Tooltip; - - /** - * Align left action label. - */ - public static String AlignmentAction_AlignLeftAction_Label; - - /** - * Align left action tooltip. - */ - public static String AlignmentAction_AlignLeftAction_Tooltip; - - /** - * Align middle action label. - */ - public static String AlignmentAction_AlignMiddleAction_Label; - - /** - * Align middle action tooltip. - */ - public static String AlignmentAction_AlignMiddleAction_Tooltip; - - /** - * Align right action label. - */ - public static String AlignmentAction_AlignRightAction_Label; - - /** - * Align right action tooltip. - */ - public static String AlignmentAction_AlignRightAction_Tooltip; - - /** - * Align top action label. - */ - public static String AlignmentAction_AlignTopAction_Label; - - /** - * Align top action tooltip. - */ - public static String AlignmentAction_AlignTopAction_Tooltip; - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/EditorMessages.properties b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/EditorMessages.properties deleted file mode 100644 index 095ef07b3..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/EditorMessages.properties +++ /dev/null @@ -1,449 +0,0 @@ -############################################################################### -# Copyright (c) 2001, 2007 Oracle Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Oracle Corporation - initial API and implementation -############################################################################### -#################################################### -# Common UI resources -#################################################### -UI_Button_Add = Add -UI_Button_Edit = Edit -UI_Button_Remove = Remove -UI_Button_Add_more = Add... -UI_Button_Edit_more = Edit... - -##Message for remove confirm alerter. -Remove_Title = Confirm Remove -Remove_Msg = Are you sure you want to remove {0}? - -FindType = Find Type -FindType_Filter = Choose a type (?=any character, *=any string): -FindType_Error_CannotFindType = Can not find java class - -FacesConfigEditor_Error_OpenModel_Title = Error -FacesConfigEditor_ErrorHandlingUndoConflicts_DialogTitle=File Conflict -FacesConfigEditor_ErrorHandlingUndoConflicts_DialogMessage=There are unsaved changes that conflict with changes made outside the editor. Do you wish to discard this editor's changes? -FacesConfigEditor_Error_OpenModel = Cannot open the faces-config file, this project is not a web project. -#################################################### -# Tab's name for multipageeditor of faces-config -#################################################### -FacesConfigEditor_Introduction_TabName = Introduction -FacesConfigEditor_Overview_TabName = Overview -FacesConfigEditor_Pageflow_TabName = Navigation Rule -FacesConfigEditor_ManagedBeans_TabName = ManagedBean -FacesConfigEditor_Components_TabName = Component -FacesConfigEditor_Others_TabName = Others -FacesConfigEditor_Source_TabName = Source - - -#################################################### -#Introduction page -#################################################### -editor_pageflow_page_intro_name = Introduction -editor_pageflow_page_intro_title = Faces Configuration Introduction -editor_pageflow_page_intro_help_HelpContextID = com.sybase.stf.jmt.faces_config_editor_introduction -editor_pageflow_page_intro_help_HelpToolTip = Introduction - -#################################################### -#ManagedBean page -#################################################### -ManagedBeanPage_Title = Faces Configuration Managed Bean - -##managed bean section -ManagedBeanMasterSection_Name = Managed Bean Elements -ManagedBeanMasterSection_Description = The following managed beans are defined - - -##managed bean general section -ManagedBeanGeneralSection_Name = Managed Bean - -ManagedBeanGeneralSection_Desc = This section describes general configuration of this managed bean - -ManagedBeanGeneralSection_ManagedBeanName = Managed Bean name*: -ManagedBeanGeneralSection_ManagedBeanClass = Managed Bean class*: -ManagedBeanGeneralSection_ManagedBeanScope = Managed Bean scope*: - -##managed bean initialization section -InitializationSection_Name = Initialization -InitializationSection_Description = You can initialize the managed bean's properties or itself if it is a subclass of java.util.Map or java.util.List - -ManagedBeanPropertyEditDialog_Title_NewPropertyEntry = Create New Property -ManagedBeanPropertyEditDialog_Title_ExistingPropertyEntry = Edit Existing Property -ManagedBeanPropertyEditDialog_PropertyName = Property name*: -ManagedBeanPropertyEditDialog_PropertyClass = Property class*: -ManagedBeanPropertyEditDialog_PropertyClass_Browse = Browse... -ManagedBeanPropertyEditDialog_ValueType = Value type: -ManagedBeanProeprtyEditPage_Description = Editing managed bean property. -ManagedBeanPropertyEditDialog_Value = Value: -ManagedBeanPropertyEditWizard_Title = Editing Managed Bean Property -ManagedBeanProeprtyEditPage_Title = Edit Property -ManagedBeanPropertyEditDialog_Value_Change = Edit... - -ManagedBeanPropertyEditDialog_FindType = Find Type -ManagedBeanPropertyEditDialog_FindType_Filter = Choose a type (?=any character, *=any string): - -InitializationSection_ClassType = Managed Bean class type: - -InitializationSection_ClassType_General = General class -InitializationSection_ClassType_Map = Map -InitializationSection_ClassType_List = List - -InitializationSection_PropertyTable_Name = Name -InitializationSection_PropertyTable_Class = Class -InitializationSection_PropertyTable_Value = Value - -InitializationSection_MapType_KeyClass = Key class: -InitializationSection_MapType_ValueClass = Value class: - -InitializationSection_MapTable_Title = Values: -InitializationSection_MapTable_Key = Key - -InitializationSection_MapTable_Value = Value - -InitializationSection_ListType_ValueClass = Value class: -InitializationSection_ListTable_Title = Values: -InitializationSection_ListTable_Value = Value - - -##ListEntriesEditGroup -ListEntriesEditPage_Title = Editing list-entries -ListEntriesWizard_Title = Editing list-entries -ListEntriesEditPage_Description = Editing list-entries of managed bean property. - - - -#################################################### -#Overview Page -#################################################### -#OverviewPage.help = Help -OverviewPage_page_name = Overview -OverviewPage_page_id = PageflowOverview -OverviewPage_page_title = PageFlow Overview -OverviewPage_PageflowOverview_summary = Faces Configuration Overview - -# editor section -OverviewPage_EditorSection_name = Editors Information -OverviewPage_EditorSection_description = This section information about editors -OverviewPage_EditorSection_noplugin = No plugin.xml file -OverviewPage_EditorSection_nooverview = No Overview section found in plugin.xml file - -# general section -OverviewPage_GeneralSection_name = General information of faces-config.xml -OverviewPage_GeneralSection_description = This section describes general information -OverviewPage_GeneralSection_label_name = Faces Config Name: -OverviewPage_GeneralSection_label_version = Version: - -#navigation section -OverviewPage_NavigationSection_name = Navigation Information -OverviewPage_NavigationSection_description = This section describes the navigation rules -OverviewPage_NavigationSection_table_col1 = From View ID -OverviewPage_NavigationSection_table_col2 = From Outcome -OverviewPage_NavigationSection_table_col3 = To View ID -OverviewPage_NavigationSection_pageflowPageID = org.eclipse.wtp.jsf.facesconfig.editor.pageflow.PageflowEditor - - -# managed bean section -OverviewPage_ManagedBeanSection_name = ManagedBean Information -OverviewPage_ManagedBeanSection_description = This section describes the managed beans -OverviewPage_ManagedBeanSection_table_namecol = Name -OverviewPage_ManagedBeanSection_table_scopecol = Scope -OverviewPage_ManagedBeanSection_table_classcol = Class -OverviewPage_ManagedBeanSection_managedbeanPageID = com.sybase.stf.jmt.editors.pageflow.managedbean.DataBindingPage - -#components section -OverviewPage_ComponentsSection_name = Component Information -OverviewPage_ComponentsSection_description = This section describes component, render-kit, converter and validator elements -OverviewPage_ComponentsSection_table_typecol = Element Type -OverviewPage_ComponentsSection_table_namecol = Element Name -OverviewPage_ComponentsSection_componentsPageID = com.sybase.stf.jmt.editors.pageflow.components.ComponentsPage - -#other section -OverviewPage_OthersSection_name = Others Information -OverviewPage_OthersSection_description = This section describes application, factory and lifecycle elements -OverviewPage_OthersSection_table_typecol = Element Type -OverviewPage_OthersSection_table_namecol = Element Name -OverviewPage_OthersSection_table_valuecol = Element Value -OverviewPage_OthersSection_othersPageID = com.sybase.stf.jmt.editors.pageflow.OthersPage - -ManagedBeanPropertyGroup_error_EmptyName = The property name should be selected. -ManagedBeanPropertyGroup_error_EmptyClass = The property class should be selected or input. -MapEntriesEditGroup_Edit = Edit... -MapEntriesEditPage_Title = Editing map-entries -MapEntriesWizard_Title = Editing map-entries -MapEntryEditGroup_Key = Key*: -MapEntryEditGroup_error_EmptyKey = The key is empty. -MapEntryEditGroup_error_DuplicateKey = The key ''{0}'' is duplicated. - - -MapEntryEditPage_Title = Edit map-entry -MapEntryEditWizard_Title = Edit Map Entry -MapEntriesEditPage_Description = Editing map-entries of managed bean property. -MapEntryEditPage_Description = Editing map-entry of managed bean property. -ValueEditDialog_Title = Edit Value -ValueEditWizard_Title = Edit Value -ValueEditPage_Description = Editing value of managed bean property. -ValueEditGroup_Value = Value: -ValueEditPage_Title = Edit Value - -#################################################### -#Components page -#################################################### -ComponentsPage_Title = Faces Configuration Components - -##Component Master Section -ComponentMasterSection_Name = Components -ComponentMasterSection_Description = The following components are defined: - - -##Components General Section -ComponentGeneralSection_Name = General -ComponentGeneralSection_Description = This section describes the general information of this component. -ComponentGeneralSection_Label_DisplayName = Display Name: -ComponentGeneralSection_Label_Description = Description: -ComponentGeneralSection_Label_ComponentType = Component Type*: -ComponentGeneralSection_Label_ComponentClass = Component Class*: - -##RenderKit Master Section -RenderKitMasterSection_Name = Render Kits -RenderKitMasterSection_Description = The following render-kits are defined: - - -##RenderKits General Section -RenderKitGeneralSection_Name = General -RenderKitGeneralSection_Description = This section describes the general information of this render-kit. -RenderKitGeneralSection_Label_DisplayName = Display Name: -RenderKitGeneralSection_Label_Description = Description: -RenderKitGeneralSection_Label_RenderKitID = Renderkit ID: -RenderKitGeneralSection_Label_RenderKitClass = Renderkit Class: - -##Renderer Section -RendererSection_Name = Renderers -RendererSection_Description = This section lists all the renderers of this render-kit. -RendererSection_Table_NameColumn = Name -RendererSection_Table_ComponentFamilyColumn = Component Family -RendererSection_Table_TypeColumn = Type -RendererSection_Table_ClassColumn = Class - -##Add/Edit Renderer Dialog -RendererSection_Dialog_Title_Add = Add Renderer -RendererSection_Dialog_Title_Edit = Edit Renderer -RendererSection_Dialog_Tab_General = General -RendererSection_Dialog_DisplayName = Display Name: -RendererSection_Dialog_ComponentFamilyValue = Component Family*: -RendererSection_Dialog_TypeValue = Renderer Type*: -RendererSection_Dialog_RendererClass = Renderer Class*: -RendererSection_Dialog_Error_ComponentFamilyEmpty = The component family is empty. -RendererSection_Dialog_Error_RendererTypeEmpty = The renderer type is empty. -RendererSection_Dialog_Error_RendererClassEmpty = The renderer class is empty. - -RendererSection_Dialog_SelectComponentFamilyDialog_Title = Select Component Family -#RendererSection.Dialog.Page.SelectComponentFamilyDialogPage.Title = Select Component Family -#RendererSection.Dialog.Page.SelectComponentFamilyDialogPage.Description = Enter or select a component family. -#RendererSection.Dialog.Page.SelectComponentFamilyDialogPage.LabelText = Enter or select a component family: -RendererSection_Dialog_ComponentFamilyCaption = Select Component Family -RendererSection_Dialog_ComponentFamilyLabel = Enter or select a component family: -##Converter Master Section -ConverterMasterSection_Name = Converters -ConverterMasterSection_Description = The following Converters are defined: - - -##Converter General Section -ConverterGeneralSection_Name = General -ConverterGeneralSection_Description = This section describes the general information of this converter. -ConverterGeneralSection_Label_DisplayName = Display Name: -ConverterGeneralSection_Label_Description = Description: -ConverterGeneralSection_Label_ConverterID = Converter ID: -ConverterGeneralSection_Label_ConverterForClass = or Converter For Class: -ConverterGeneralSection_Label_ConverterClass = Converter Class*: - -##Validator Section -ValidatorMasterSection_Name = Validators -ValidatorMasterSection_Description = The following Validators are defined: - - -##Validator General Section -ValidatorGeneralSection_Name = General -ValidatorGeneralSection_Description = This section describes general information of this Validator -ValidatorGeneralSection_Label_DisplayName = Display Name: -ValidatorGeneralSection_Label_Description = Description: -ValidatorGeneralSection_Label_ValidatorID = Validator ID*: -ValidatorGeneralSection_Label_ValidatorClass = Validator Class*: - -##Attribute Section -AttributeSection_Name = Attributes -AttributeSection_Description = This section lists all the attributes. - -AttributeSection_Table_NameColumn = Name -AttributeSection_Table_ClassColumn = Class -AttributeSection_Table_DefaultValueColumn = Default Value -AttributeSection_Table_SuggestedValueColumn = Suggested Value - -##Add/Edit Attribute Dialog -AttributeSection_Dialog_Title_Add = Add Attribute -AttributeSection_Dialog_Title_Edit = Edit Attribute -AttributeSection_Dialog_Tab_General = General -AttributeSection_Dialog_AttributeName = Attribute Name*: -AttributeSection_Dialog_AttributeClass = Attribute Class*: -AttributeSection_Dialog_DefaultValue = Default value: -AttributeSection_Dialog_SuggestedValue = Suggested value: -AttributeSection_Dialog_Error_NameEmpty = The attribute name is empty. -AttributeSection_Dialog_Error_ClassEmpty = The attribute class is empty. - -##Property Section -PropertySection_Name = Properties -PropertySection_Description = This section lists all the properties. - -PropertySection_Table_NameColumn = Name -PropertySection_Table_ClassColumn = Class -PropertySection_Table_DefaultValueColumn = Default Value -PropertySection_Table_SuggestedValueColumn = Suggested Value - - -##Add/Edit Property Dialog -PropertySection_Dialog_Title_Add = Add Property -PropertySection_Dialog_Title_Edit = Edit Property -PropertySection_Dialog_Tab_General = General -PropertySection_Dialog_PropertyName = Property Name*: -PropertySection_Dialog_PropertyClass = Property Class*: -PropertySection_Dialog_DefaultValue = Default value: -PropertySection_Dialog_SuggestedValue = Suggested value: -PropertySection_Dialog_Error_NameEmpty = The property name is empty. -PropertySection_Dialog_Error_ClassEmpty = The property class is empty. - -##Facet Section -FacetSection_Name = Facets -FacetSection_Description = This section lists all the facets. - -FacetSection_Table_DisplayNameColumn = Display Name -FacetSection_Table_FacetNameColumn = Facet Name -FacetSection_Table_DescriptionColumn = Description - -FacetSection_Dialog_Title_Add = Add Facet -FacetSection_Dialog_Title_Edit = Edit Facet -FacetSection_Dialog_Tab_General = General -FacetSection_Dialog_FacetName = Facet Name*: -FacetSection_Dialog_DisplayName = Display Name: -FacetSection_Dialog_Description = Description: -FacetSection_Dialog_Error_NameEmpty = The facet name is empty. - -#################################################### -#Others page -#################################################### -OthersPage_Title = Faces Configuration Others - -##Application ActionListener Section -ActionListenerSection_Name = Action Listener -ActionListenerSection_Description = - - -##Application Message Bundle Section -MessageBundleSection_Name = Message Bundle -MessageBundleSection_Description = - - -MessageBundleSection_Dialog_Title = Select Message Bundle -MessageBundleSection_Dialog_Message_SelectPropertyFile = Please select a message bundle file. -MessageBundleSection_Dialog_Message_AlreadyExists = This message bundle already exists. - -##Application Locale Config Section -LocaleConfigSection_Name = Locale Config -LocaleConfigSection_Description = - -LocaleConfigSection_Wizard_WindowTitle = Add New Locale -LocaleConfigSection_Wizard_Page_Name = addLocalePage -LocaleConfigSection_Wizard_Page_Title = Add Supported Locale -LocaleConfigSection_Wizard_Page_Description = -LocaleConfigSection_Wizard_Page_LabelText = Enter or select a locale: -LocaleConfigSection_Wizard_Page_AlreadyExistsError = This locale already exists. - -##Application Default RenderKit ID Section -DefaultRenderKitIDSection_Name = Default RenderKit ID -DefaultRenderKitIDSection_Description = - - -DefaultRenderKitIDSection_Wizard_WindowTitle = Add Default Render Kit ID -DefaultRenderKitIDSection_Wizard_Page_Name = addDefaultRenderKitIDPage -DefaultRenderKitIDSection_Wizard_Page_Title = Add Default Render Kit ID -DefaultRenderKitIDSection_Wizard_Page_Description = -DefaultRenderKitIDSection_Wizard_Page_LabelText = Enter or select a render kit id: -DefaultRenderKitIDSection_Wizard_Page_AlreadyExistsError = This render kit ID already exists. - -##Application Navigation Handler Section -NavigationHandlerSection_Name = Navigation Handler -NavigationHandlerSection_Description = - - -##Application View Handler Section -ViewHandlerSection_Name = View Handler -ViewHandlerSection_Description = - - -##Application State Manager Section -StateManagerSection_Name = State Manager -StateManagerSection_Description = - - -##Application Property Resolver Section -PropertyResolverSection_Name = Property Resolver -PropertyResolverSection_Description = - -##Application Variable Resolver Section -VariableResolverSection_Name = Variable Resolver -VariableResolverSection_Description = - - -##Factory Application Factory Section -ApplicationFactorySection_Name = Application Factory -ApplicationFactorySection_Description = - - -##Factory Faces Context Factory Section -FacesContextFactorySection_Name = Faces Context Factory -FacesContextFactorySection_Description = - - -##Factory Lifecycle Factory Section -LifecycleFactorySection_Name = Lifecycle Factory -LifecycleFactorySection_Description = - - -##Factory Render Kit Factory Section -RenderKitFactorySection_Name = Render Kit Factory -RenderKitFactorySection_Description = - -##LifeCycle Phase Listener Section -PhaseListenerSection_Name = Phase Listener -PhaseListenerSection_Description = - -#################################################### -#Resource for MultiPageEditorOutlinePage -#################################################### -MultiPageEditorOutlinePage_noOutline = An outline is not available. - - -FacesConfigEditor_WaitForLoadPage_Title= Please wait while the editor finishes loading... -FacesConfigEditor_WaitForLoad_EditorTabTitle=Wait for Load -ModelLoader_LoadingModelJobName="Loading faces-config model" - -########################### -# AlignmentAction messages -########################### -AlignmentAction_AlignLeftAction_Tooltip=Align Left -AlignmentAction_AlignLeftAction_Label=Align &Left -AlignmentAction_AlignRightAction_Tooltip=Align Right -AlignmentAction_AlignRightAction_Label=Align &Right -AlignmentAction_AlignTopAction_Tooltip=Align Top -AlignmentAction_AlignTopAction_Label=Align &Top -AlignmentAction_AlignBottomAction_Tooltip=Align Bottom -AlignmentAction_AlignBottomAction_Label=Align &Bottom -AlignmentAction_AlignCenterAction_Tooltip=Align Center -AlignmentAction_AlignCenterAction_Label=Align &Center -AlignmentAction_AlignMiddleAction_Tooltip=Align Middle -AlignmentAction_AlignMiddleAction_Label=Align &Middle -AddEditManagedPropertyDialog_Add=Add Managed Property -AddEditManagedPropertyDialog_Edit=Edit Managed Property diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/EditorPlugin.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/EditorPlugin.java deleted file mode 100644 index 69cbda413..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/EditorPlugin.java +++ /dev/null @@ -1,275 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.ImageRegistry; -import org.eclipse.jst.jsf.common.ui.internal.guiutils.Alerts; -import org.eclipse.jst.jsf.common.ui.internal.logging.Logger; -import org.eclipse.jst.jsf.facesconfig.ui.preference.GEMPreferences; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; - -/** - * The main plugin class to be used in the desktop. - */ -public class EditorPlugin extends AbstractUIPlugin {//implements IStartup { - - // The shared instance. - private static EditorPlugin plugin; - - private Logger log; - - private ResourceBundle resourceBundle; - - private static Alerts alerts; - - private URL pluginBase; - - /** - * The constructor. - */ - public EditorPlugin() { - super(); - plugin = this; - } - - - /** - * This method is called upon plug-in activation - */ - public void start(BundleContext context) throws Exception { - super.start(context); - try { - // get resource bundle. - resourceBundle = ResourceBundle - .getBundle("org.eclipse.jst.jsf.facesconfig.ui.EditorPluginResources"); - alerts = new Alerts(this, resourceBundle); - pluginBase = getBundle().getEntry("/"); - - // set up logging for this plugin and everthing under it. - log = new Logger(this.getBundle(), resourceBundle); - - // log.info("log.StartMessage", CommonPlugin.getVersion()); - } catch (Exception ee) { - // only log if the logger was configured correctly. - if (log != null) { - log.error("log.msg", - "Problems starting plug-in Faces Config Editor.", ee); - } - - throw new CoreException(new Status(IStatus.ERROR, getBundle() - .getSymbolicName(), IStatus.OK, - "Problems starting plug-in Faces Config Editor", ee)); - } - - } - - /** - * This method is called when the plug-in is stopped - */ - public void stop(BundleContext context) throws Exception { - super.stop(context); - plugin = null; - } - - /** - * Returns the shared instance. - */ - public static EditorPlugin getDefault() { - return plugin; - } - - /** - * @return the alerts objects associated with this plugin for alerting the user. - */ - public static Alerts getAlerts() { - return alerts; - } - - /** - * Returns a logger for the new class using this plugin for reference. - */ - public static Logger getLogger(Class theClass) { - return getDefault().getRootLogger(); // .getLogger(theClass); - } - - /** - * Returns the plugin's root logger - */ - public Logger getRootLogger() { - return log; - } - - /** - * Returns the plugin's resource bundle, - */ - public ResourceBundle getResourceBundle() { - return resourceBundle; - } - - /** - * Returns the string from the plugin's resource bundle, or 'key' if not - * found. - */ - public static String getResourceString(String key) { - ResourceBundle bundle = getDefault().getResourceBundle(); - try { - return (bundle != null) ? bundle.getString(key) : key; - } catch (MissingResourceException e) { - return key; - } - } - - /** - * Returns the standard display to be used. The method first checks, if the - * thread calling this method has an associated dispaly. If so, this display - * is returned. Otherwise the method returns the default display. - */ - public static Display getStandardDisplay() { - Display display; - display = Display.getCurrent(); - if (display == null) { - display = Display.getDefault(); - } - return display; - } - - /** - * Returns the active workbench window. - * - * @return the active workbench window. this can be null but I've never seen - * it. - */ - public static IWorkbenchWindow getActiveWorkbenchWindow() { - if (getDefault().getWorkbench() == null) { - return null; - } - return getDefault().getWorkbench().getActiveWorkbenchWindow(); - } - - public static Shell getActiveShell() { - Shell shell = null; - IWorkbenchWindow workbenchWindow = getActiveWorkbenchWindow(); - if (workbenchWindow.getShell() != null) { - shell = workbenchWindow.getShell(); - } else { - shell = new Shell(); - } - return shell; - } - - /** - * Returns the active workbench page. Note that the active page may not be - * the one that the user perceives as active in some situations so this - * method of obtaining the activate page should only be used if no other - * method is available. - * - * @return the active workbench page - */ - public static IWorkbenchPage getActivePage() { - IWorkbenchWindow window = getActiveWorkbenchWindow(); - if (window == null) { - return null; - } - return window.getActivePage(); - } - - /** - * Returns a shared image for the given name - * <p> - * Note: Images returned from this method will be automitically disposed of - * when this plug-in shuts down. Callers must not dispose of these images - * themselves. - * </p> - * - * @param name - * the image name found in /icons (with extension) - * @return the image, null on error or not found. - */ - public Image getImage(String name) { - if (name == null) { - return null; - } - - ImageRegistry images = getImageRegistry(); - Image image = images.get(name); - if (image == null) { - try { - ImageDescriptor id = ImageDescriptor.createFromURL(new URL( - pluginBase, "icons/" + name)); - images.put(name, id); - - image = images.get(name); - } catch (MalformedURLException ee) { - // log.EditorPlugin.image.error=Image {0} not found. - log.error("log.msg", "log.EditorPlugin.image.error", name, ee); - } - } - return image; - } - - /** - * Returns an image descriptor for the image file at the given plug-in - * relative path. - * - * @param path - * the path - * @return the image descriptor - */ - public ImageDescriptor getImageDescriptor(String path) { - if (path == null) { - return null; - } - - ImageRegistry images = getImageRegistry(); - ImageDescriptor id = images.getDescriptor(path); - if (id == null) { - try { - id = ImageDescriptor.createFromURL(new URL(pluginBase, "icons/" - + path)); - images.put(path, id); - } catch (MalformedURLException ee) { - // log.EditorPlugin.image.error=Image {0} not found. - log.error("log.msg", "log.EditorPlugin.image.error", path, ee); - } - } - return id; - } - - /** - * Returns this plugin's unique identifier - * - * @retun this plugin's unique identifier - * - */ - public static String getPluginId() { - return getDefault().getBundle().getSymbolicName(); - } - - protected void initializeDefaultPluginPreferences() { - new GEMPreferences(); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/EditorPluginResources.properties b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/EditorPluginResources.properties deleted file mode 100644 index c8eef1a5a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/EditorPluginResources.properties +++ /dev/null @@ -1,85 +0,0 @@ -############################################################################### -# Copyright (c) 2001, 2006 Oracle Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Oracle Corporation - initial API and implementation -############################################################################### -common.error=Error -common.warning=Warning -log.StartMessage=Faces Config Editor initialized on eclipse version {0}. -#################################################### -# Resource message for Logging -#################################################### - -log.msg={0} - -log.EditorPlugin=Faces Config Editor Plugin initialized on eclipse version {0}. -log.EditorPlugin.image.error=Image {0} not found. - -#################################################### -# Resource message for Alert -#################################################### - -Pageflow.PageflowEditor.Alert.errorOpenEditorTitle = Open Pageflow Error -Pageflow.PageflowEditor.Alert.errorOpenEditorInfo = An error occured during opening the editor. -Pageflow.PageflowEditor.Alert.errorSaveFileTitle = Save Pageflow Error -Pageflow.PageflowEditor.Alert.errorSaveFileInfo = The current pageflow model could not be saved. -Pageflow.PageflowEditor.Alert.nullModelManager = No model manager found for saving the file. -Pageflow.PageflowEditor.Alert.errorOpenEditor4JSFTitle = Open JSF File Error -Pageflow.PageflowEditor.Alert.errorOpenEditor4JSFInfo = The JSF file ''{0}'' does not exist. -Pageflow.PageflowEditor.Alert.errorOpenEditor4JSFFolderInfo = Cannot open the page in the page editor. - -Pageflow.PageflowEditor.Alert.confirmCreateNewJSFFileTitle = Confirm -Pageflow.PageflowEditor.Alert.confirmCreateNewJSFFile = No jsp file is related with this page. - -Pageflow.PageflowEditor.Alert.syncWithFacesConfigTitle = Confirm -Pageflow.PageflowEditor.Alert.syncWithFacesConfigInfo = Synchronizing with faces-config will update the current pageflow model! \nThis command CAN NOT undo. Are you sure? -Pageflow.PageflowEditor.Alert.errorSyncPageflowModel = The current pageflow model could not be synchronized with the specified faces-config file. - -Pageflow.PageflowEditor.Alert.updateFacesConfigTitle = Confirm -Pageflow.PageflowEditor.Alert.updateFacesConfigInfo = Update the related faces config file! are you sure? -Pageflow.PageflowEditor.Alert.errorUpdateFacesConfig = The related faces-config file could not be updated! - -Pageflow.Transform.Alert.ResourceTitle = Resource Error -Pageflow.Transform.Alert.LoadResourceError = Error loading resource -Pageflow.Transform.Alert.SaveResourceError = Error saving resource - -Pageflow.PageflowEditor.Alert.DNDResourceTitle = Pageflow Creation Error -Pageflow.PageflowEditor.Alert.ExistingPage = The web page {0} is already existed in current PageFlow. -Pageflow.PageflowEditor.Alert.ExistingAction = The action {0} is already existed in current PageFlow. -Pageflow.PageflowEditor.Alert.PageFromOtherProject = The web page {0} does not belong to current project. - -Pageflow.FacesConfig.Alert.ResourceTitle = Faces Configuration File Warning -Pageflow.FacesConfig.Alert.LoadFileError = Invalid content in faces configuration file ''{0}''. -Pageflow.FacesConfig.Alert.ErrorUpdateFacesConfigFromPageflow = Invalid content in faces configuration file. \nThe pageflow diagram can not be transformed. -Pageflow.FacesConfig.Alert.SaveFileError = Failed to save faces configuration file ''{0}''. - -ManagedBeanInitializationSection.Remove.Title = Confirm Remove -ManagedBeanInitializationSection.RemoveManagedProperty = Are you sure you want to remove all the managed-properties? -ManagedBeanInitializationSection.RemoveMapEntries = Are you sure you want to remove map-entries? -ManagedBeanInitializationSection.RemoveListEntries = Are you sure you want to remove list-entries? - -Alert.Error.CompletionProcessor.HTML.AttributeCompletionProp=No completions found -Alert.Info.JSPPageEditorContributor.CreateAction.Message=Sample Action Executed - -Pageflow.PageflowEditor.Error.invalidPageflowFile = The specified input is not a valid pageflow. -Pageflow.PageflowEditor.Error.invalidPageflowModel = The model in the pageflow file is not a valid pageflow model. -Pageflow.PageflowEditor.Error.canNotOpenEditor4JSF = The jsf file can not be opened in the editor. -Pageflow.PageflowEditor.Error.ResourceChange = Failed in the resource change. -Pageflow.PageflowEditor.Error.canNotShowPropertyView = Failed to show property sheet view. -Pageflow.PageflowEditor.Error.canNotShowPaletteView = Failed to show palette sheet view. - -Pageflow.PageflowResources.Error.invalidResourceBundle = The specified resource file is not a valid resourece bundle file. -Pageflow.Transform.Resource.LoadError = Error loading resource {0} - -Pageflow.PageflowEditor.Error.UnableRemoveAllMarkers = Unable to remove all markers -Pageflow.PageflowEditor.Error.UnableAddMarker = Unable to add a marker -Pageflow.PageflowEditor.Error.UnableRemoveMarker = Unable to remove a marker -Pageflow.PageflowEditor.Error.invalidMarkerAttribute = Unable to get marker's attribute - -PageflowEditor.Encoding.Unsupported = Unsupported Encoding. -PageflowEditor.Transform.Error.GetPageflowFromFacesConfig = Failed to get pageflow model from faces-config'a navigation rule. diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/FacesConfigActionBarContributor.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/FacesConfigActionBarContributor.java deleted file mode 100644 index c8b00f232..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/FacesConfigActionBarContributor.java +++ /dev/null @@ -1,179 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui; - -import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor; -import org.eclipse.jface.action.ICoolBarManager; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IStatusLineManager; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowActionBarContributor; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowEditor; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.part.EditorActionBarContributor; -import org.eclipse.ui.part.MultiPageEditorActionBarContributor; -import org.eclipse.wst.sse.ui.StructuredTextEditor; -import org.eclipse.wst.xml.ui.internal.tabletree.SourcePageActionContributor; - -/** - * The faces-config editor itself is composed by a set of pages. Each page has - * its own action contributor. This FacesConfigActionBarContributor will work as - * a proxy to delegate the action contributing to target nested action - * contributor. - * - * @author hmeng - */ - -public class FacesConfigActionBarContributor extends - MultiPageEditorActionBarContributor { - protected SourcePageActionContributor sourceActionContributor = null; - - protected PageflowActionBarContributor pageflowActionContributor = null; - - protected EditingDomainActionBarContributor formbasedPageActionContributor = null; - - private IEditorPart activeNestedEditor; - - //private IEditorPart targetEditor; - - public FacesConfigActionBarContributor() { - super(); - } - - public void setActivePage(IEditorPart activeEditor) { - if (activeEditor != activeNestedEditor) { - if (getActionContributor(activeNestedEditor) != null) { - getActionContributor(activeNestedEditor).setActiveEditor( - activeEditor); - } - activeNestedEditor = activeEditor; - EditorActionBarContributor activeContributor = getActionContributor(activeEditor); - if (activeContributor != null) - activeContributor.setActiveEditor(activeEditor); - else - super.setActiveEditor(activeEditor); - updateActionBars(); - } - } - - public void contributeToCoolBar(ICoolBarManager coolBarManager) { - EditorActionBarContributor activeContributor = getActionContributor(activeNestedEditor); - if (activeContributor != null) - activeContributor.contributeToCoolBar(coolBarManager); - } - - public void contributeToMenu(IMenuManager menuManager) { - EditorActionBarContributor activeContributor = getActionContributor(activeNestedEditor); - if (activeContributor != null) { - activeContributor.contributeToMenu(menuManager); - } - } - - public void contributeToStatusLine(IStatusLineManager statusLineManager) { - EditorActionBarContributor activeContributor = getActionContributor(activeNestedEditor); - if (activeContributor != null) { - activeContributor.contributeToStatusLine(statusLineManager); - } - } - - public void contributeToToolBar(IToolBarManager toolBarManager) { - EditorActionBarContributor activeContributor = getActionContributor(activeNestedEditor); - if (activeContributor != null) { - activeContributor.contributeToToolBar(toolBarManager); - } - } - - public void dispose() { - getFormbasedPageActionContributor().dispose(); - getPageflowActionContributor().dispose(); - getSourceActionContributor().dispose(); - } - - public IActionBars getActionBars() { - EditorActionBarContributor activeContributor = getActionContributor(activeNestedEditor); - if (activeContributor != null) { - return activeContributor.getActionBars(); - } - return super.getActionBars(); - } - - public IWorkbenchPage getPage() { - return super.getPage(); - } - - public void init(IActionBars bars, IWorkbenchPage page) { - getPageflowActionContributor().init(bars, page); - getSourceActionContributor().init(bars, page); - getFormbasedPageActionContributor().init(bars, page); - super.init(bars, page); - } - -// private IEditorPart getActiveNestedEditor(IEditorPart targetEditor) { -// IEditorPart activeNestedEditor_; -// if (targetEditor instanceof FormEditor) { -// activeNestedEditor_ = ((FormEditor) targetEditor).getActiveEditor(); -// } else { -// activeNestedEditor_ = targetEditor; -// } -// return activeNestedEditor_; -// } - - private EditorActionBarContributor getActionContributor( - IEditorPart activeNestedEditor_) { - EditorActionBarContributor activeContributor = null; - if (activeNestedEditor_ instanceof PageflowEditor) { - activeContributor = getPageflowActionContributor(); - } else if (activeNestedEditor_ instanceof StructuredTextEditor) { - activeContributor = getSourceActionContributor(); - } else if (activeNestedEditor_ != null) { - activeContributor = getFormbasedPageActionContributor(); - } - return activeContributor; - } - - public SourcePageActionContributor getSourceActionContributor() { - if (sourceActionContributor == null) { - sourceActionContributor = new SourcePageActionContributor(); - } - return sourceActionContributor; - } - - public EditingDomainActionBarContributor getFormbasedPageActionContributor() { - if (formbasedPageActionContributor == null) { - formbasedPageActionContributor = new MyEditingDomainActionContributor(); - } - return formbasedPageActionContributor; - } - -// protected void declareGlobalActionKeys() { -// // -// } - - public PageflowActionBarContributor getPageflowActionContributor() { - if (pageflowActionContributor == null) { - pageflowActionContributor = new PageflowActionBarContributor(); - } - return pageflowActionContributor; - - } - - public void updateActionBars() { - EditorActionBarContributor activeContributor = getActionContributor(activeNestedEditor); - if (activeContributor instanceof INestedActionContributor) - ((INestedActionContributor) activeContributor).update(); - // getActionBars().getMenuManager().removeAll(); - // activeContributor.contributeToMenu(getActionBars().getMenuManager()); - getActionBars().updateActionBars(); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/FacesConfigEditor.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/FacesConfigEditor.java deleted file mode 100644 index 0df29c38b..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/FacesConfigEditor.java +++ /dev/null @@ -1,1368 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.EventObject; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Set; -import java.util.concurrent.atomic.AtomicBoolean; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.IResourceDeltaVisitor; -import org.eclipse.core.resources.ResourcesPlugin; -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.Status; -import org.eclipse.emf.common.command.BasicCommandStack; -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain; -import org.eclipse.emf.edit.domain.EditingDomain; -import org.eclipse.emf.edit.domain.IEditingDomainProvider; -import org.eclipse.emf.edit.provider.ComposedAdapterFactory; -import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory; -import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory; -import org.eclipse.gef.commands.CommandStack; -import org.eclipse.gef.commands.CommandStackListener; -import org.eclipse.gef.editparts.ZoomManager; -import org.eclipse.gef.ui.actions.ActionRegistry; -import org.eclipse.gef.ui.actions.EditorPartAction; -import org.eclipse.gef.ui.actions.SaveAction; -import org.eclipse.gef.ui.actions.UpdateAction; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jst.jsf.common.ui.internal.actions.IOpenPage; -import org.eclipse.jst.jsf.core.IJSFCoreConstants; -import org.eclipse.jst.jsf.facesconfig.edit.provider.FacesConfigItemProviderAdapterFactory; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigType; -import org.eclipse.jst.jsf.facesconfig.ui.page.ComponentsPage; -import org.eclipse.jst.jsf.facesconfig.ui.page.IntroductionPage; -import org.eclipse.jst.jsf.facesconfig.ui.page.ManagedBeanPage; -import org.eclipse.jst.jsf.facesconfig.ui.page.OthersPage; -import org.eclipse.jst.jsf.facesconfig.ui.page.OverviewPage; -import org.eclipse.jst.jsf.facesconfig.ui.page.WaitForLoadPage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.DelegatingZoomManager; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowEditor; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.DelegatingCommandStack; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.EMFCommandStackGEFAdapter; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.layout.PageflowLayoutManager; -import org.eclipse.jst.jsf.facesconfig.ui.preference.GEMPreferences; -import org.eclipse.jst.jsf.facesconfig.util.FacesConfigArtifactEdit; -import org.eclipse.swt.custom.CTabFolder; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IEditorActionBarContributor; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorSite; -import org.eclipse.ui.IFileEditorInput; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.WorkspaceModifyOperation; -import org.eclipse.ui.dialogs.SaveAsDialog; -import org.eclipse.ui.forms.editor.FormEditor; -import org.eclipse.ui.forms.editor.FormPage; -import org.eclipse.ui.forms.editor.IFormPage; -import org.eclipse.ui.ide.IDE; -import org.eclipse.ui.ide.IGotoMarker; -import org.eclipse.ui.part.FileEditorInput; -import org.eclipse.ui.views.contentoutline.IContentOutlinePage; -import org.eclipse.ui.views.properties.IPropertySheetPage; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.IProjectFacet; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; -import org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySheetPageContributor; -import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetPage; -import org.eclipse.wst.sse.core.StructuredModelManager; -import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; -import org.eclipse.wst.sse.ui.StructuredTextEditor; - -/** - * This is the main editor for the faces-config file. Note that the model - * load can involve long-running socket operations (shouldn't but can), - * so the editor UI is load asynchronously. This is means that any - * operations that need to be executed on editor open should be run - * using AddPagesTask.pageSafeExecute() to ensure that they occur - * after all editor pages have finished loading. - * - * @author sfshi - * - */ -public class FacesConfigEditor extends FormEditor implements - IEditingDomainProvider, ISelectionProvider { - - /** - * This editor's ID. TODO: this should prob be in plugin.properties? - */ - public static final String EDITOR_ID = "org.eclipse.jst.jsf.facesconfig.ui.FacesConfigEditor"; //$NON-NLS-1$ - - /** - * editing domain that is used to track all changes to the model - */ - private AdapterFactoryEditingDomain editingDomain; - - /** - * adapter factory used for providing views of the model - */ - private ComposedAdapterFactory adapterFactory; - - /** id of the pageflowPage */ - private int pageflowPageID; - - private int managedBeanPageID; - - private int componentsPageID; - - private int othersPageID; - - private int sourcePageId; - - private PageflowEditor pageflowPage; - - /** The source text editor. */ - private StructuredTextEditor sourcePage; - - private Collection selectionChangedListeners = new ArrayList(); - - private ISelection editorSelection = StructuredSelection.EMPTY; - - private IContentOutlinePage outlinePage; - - private IProject currentProject; - - private boolean isWebProject; - - private ModelLoader _modelLoader; - - /** - * only true once dispose() has been called - * used to signal that the editor was disposed. - */ - private boolean _isDisposed; // = false; - - /** - * Used to load editor pages when the model is loaded - */ - private final AddPagesTask _addPagesTask = new AddPagesTask(); - - /** - * Default constructor - */ - public FacesConfigEditor() { - initializeEMF(); - } - - /** - * This listens for workspace changes. <!-- begin-user-doc --> <!-- - * end-user-doc --> - * - * @generated - */ - protected IResourceChangeListener resourceChangeListener = new IResourceChangeListener() { - public void resourceChanged(IResourceChangeEvent event) { - // Only listening to these. - // if (event.getType() == IResourceDelta.POST_CHANGE) - { - IResourceDelta delta = event.getDelta(); - try { - class ResourceDeltaVisitor implements IResourceDeltaVisitor { - protected ResourceSet resourceSet = editingDomain - .getResourceSet(); - - @SuppressWarnings("hiding") //$NON-NLS-1$ - protected Collection changedResources = new ArrayList(); - - @SuppressWarnings("hiding") //$NON-NLS-1$ - protected Collection removedResources = new ArrayList(); - - public boolean visit(IResourceDelta delta_) { - if (delta_.getFlags() != IResourceDelta.MARKERS - && delta_.getResource().getType() == IResource.FILE) { - if ((delta_.getKind() & (IResourceDelta.CHANGED | IResourceDelta.REMOVED)) != 0) { - Resource resource = resourceSet - .getResource(URI.createURI(delta_ - .getFullPath().toString()), - false); - if (resource != null) { - if ((delta_.getKind() & IResourceDelta.REMOVED) != 0) { - removedResources.add(resource); - } else { - changedResources.add(resource); - } - } - } - } - - return true; - } - - public Collection getChangedResources() { - return changedResources; - } - - public Collection getRemovedResources() { - return removedResources; - } - } - - ResourceDeltaVisitor visitor = new ResourceDeltaVisitor(); - delta.accept(visitor); - - if (!visitor.getRemovedResources().isEmpty()) { - removedResources.addAll(visitor.getRemovedResources()); - if (!isDirty()) { - getSite().getShell().getDisplay().asyncExec( - new Runnable() { - public void run() { - getSite().getPage().closeEditor( - FacesConfigEditor.this, - false); - FacesConfigEditor.this.dispose(); - } - }); - } - } - - if (!visitor.getChangedResources().isEmpty()) { - changedResources.addAll(visitor.getChangedResources()); - } - } catch (CoreException exception) { - // log it. - EditorPlugin.getDefault().getLog().log( - new Status(IStatus.ERROR, EditorPlugin - .getPluginId(), IStatus.OK, exception - .getMessage() == null ? "" : exception //$NON-NLS-1$ - .getMessage(), exception)); - } - } - } - }; - - /** - * Resources that have been removed since last activation. - * - * @generated - */ - Collection removedResources = new ArrayList(); - - /** - * Resources that have been changed since last activation. - * - * @generated - */ - Collection changedResources = new ArrayList(); - - /** - * Resources that have been saved. - * - * @generated - */ - Collection savedResources = new ArrayList(); - - /** - * Initializes the EMF support. - */ - private void initializeEMF() { - // create an adapter factory that yields item providers - List factories = new ArrayList(); - factories.add(new ResourceItemProviderAdapterFactory()); - factories.add(new FacesConfigItemProviderAdapterFactory()); - factories.add(new ReflectiveItemProviderAdapterFactory()); - adapterFactory = new ComposedAdapterFactory(factories); - - // create the command stack that will notify this editor as commands are - // executed - BasicCommandStack commandStack = new BasicCommandStack(); - commandStack - .addCommandStackListener(new org.eclipse.emf.common.command.CommandStackListener() { - public void commandStackChanged(final EventObject event) { - getContainer().getShell().getDisplay().asyncExec( - new Runnable() { - public void run() { - editorDirtyStateChanged(); - getActionBarContributor() - .updateActionBars(); - } - }); - } - }); - // commandStack.addCommandStackListener(this); - // create the editing domain with a special command stack - editingDomain = new AdapterFactoryEditingDomain(adapterFactory, - commandStack, new HashMap()); - } - - /* - * @see org.eclipse.ui.IEditorPart#init(org.eclipse.ui.IEditorSite, - * org.eclipse.ui.IEditorInput) - */ - public void init(IEditorSite site, IEditorInput input) - throws PartInitException { - try { - super.init(site, input); - } catch (Exception e) { - MessageDialog.openError(null, - EditorMessages.FacesConfigEditor_Error_OpenModel_Title, - EditorMessages.FacesConfigEditor_Error_OpenModel); - throw new PartInitException( - EditorMessages.FacesConfigEditor_Error_OpenModel); - } - - setPartName(input.getName()); - if (!isValidInput(input)) { - PlatformUI.getWorkbench().getActiveWorkbenchWindow() - .getActivePage().openEditor(input, - "org.eclipse.ui.DefaultTextEditor"); //$NON-NLS-1$ - - close(false); - return; - } - - createActions(); - - ResourcesPlugin.getWorkspace().addResourceChangeListener( - resourceChangeListener, IResourceChangeEvent.POST_CHANGE); - } - - /* - * @see org.eclipse.ui.part.EditorPart#setInput(org.eclipse.ui.IEditorInput) - */ - protected void setInput(IEditorInput input) - { - isWebProject = matches(input); - super.setInput(input); - - IFile inputFile = (IFile) input.getAdapter(IFile.class); - if (inputFile != null) - { - final IProject project = inputFile.getProject(); - final IPath inputPath = inputFile.getFullPath(); - - _modelLoader = new ModelLoader(); - _modelLoader.load(project, inputPath, isWebProject, _addPagesTask); - } - } - - - protected void addPages() - { - // try loading wait page - // if we get to here before model load completes, - // then wait page will give the user the indication - // that something is happening in the background before - // the editor full loads. - // if the model is already loaded, this call should do nothing - _addPagesTask.maybeAddWaitPage(); - } - - /** - * This runnable is used to used to manage the loading of the - * editor pages for editor in a deferred fashion. Because the model - * loading for this editor can be noticably long and (unfortunately) - * may involve socket calls that block, loadModel(), runs this on a - * separate thread. This class is intended to be used in two ways: - * - * 1) by the model loading code to signal it is finished by executing - * the run() via a display.asyncExec(). - * - * 2) by the addPages() call back on the the main editor as a way to - * load a "Please wait for loading" page if the loading is still running - * by the time the editor is ready to visualize itself. - * - * Note that in both cases methods of this class *must* be running on the - * main display thread. - * - * @author cbateman - * - */ - private class AddPagesTask extends ModelLoader.ModelLoaderComplete - { - private final AtomicBoolean _arePagesLoaded = new AtomicBoolean(false); // set to true when the regular editor pages are loaded - private FormPage _waitPage; - private List<Runnable> _deferredRunnables = new ArrayList<Runnable>(); - - /** - * If the editor pages are loaded, runnable.run() is invoked immediately - * If the editor pages are not loaded yet, runnable is queued and will be - * executed in the order they are added immediately after the pages are loaded - * - * @param runnable - */ - public synchronized void pageSafeExecute(Runnable runnable) - { - if (!_isDisposed) - { - if (!_arePagesLoaded.get()) - { - _deferredRunnables.add(runnable); - } - else - { - runnable.run(); - } - } - } - - /** - * @return true if the pages are loaded - */ - public synchronized boolean getArePagesLoaded() - { - return _arePagesLoaded.get(); - } - - /** - * Remove the wait page if present. - */ - public synchronized void removeWaitPage() - { - if (_waitPage != null) - { - int index = _waitPage.getIndex(); - - if (index >= 0) - { - removePage(index); - } - } - } - - /** - * Add the wait page if the main pages aren't already loaded - */ - public synchronized void maybeAddWaitPage() - { - // only load the wait page if the other pages haven't been loaded - if (!getArePagesLoaded()) - { - _waitPage = new WaitForLoadPage(FacesConfigEditor.this, "WaitForLoad", EditorMessages.FacesConfigEditor_WaitForLoad_EditorTabTitle); //$NON-NLS-1$ - - try - { - addPage(0,_waitPage); - } - catch(PartInitException pie) - { - _waitPage =null; - EditorPlugin.getDefault().getLog().log( - new Status(IStatus.ERROR, EditorPlugin.getPluginId(), - IStatus.OK, pie.getMessage() == null ? "" : pie //$NON-NLS-1$ - .getMessage(), pie)); - } - } - } - - /** - * Must be run on the UI thread - */ - public void doRun(FacesConfigArtifactEdit edit) - { - synchronized(this) - { - // ensure wait page gets removed - removeWaitPage(); - - if (!getArePagesLoaded() - && !_isDisposed) // NOTE: we assume that access to variable does not need to - // to be synchronous since this method must - // be run on the UI thread. The only way - // that isDisposed should be true is if model loading took a long - // time and the user closed the editor before it completed (trigger dispose to be called) - { - try - { - if (isWebProject && edit != null && edit.getFacesConfig() != null) - { - // only add the intro editor if the preference - // is set to do so. - if (GEMPreferences.getShowIntroEditor()) - { - IntroductionPage page1 = new IntroductionPage(FacesConfigEditor.this); - addPage(page1, null); - } - - IFormPage overviewPage = new OverviewPage(FacesConfigEditor.this); - addPage(overviewPage, null); - - // Page flow - createAndAddPageflowPage(); - - // pages - IFormPage managedBeanPage = new ManagedBeanPage(FacesConfigEditor.this); - managedBeanPageID = addPage(managedBeanPage, null); - IFormPage componentsPage = new ComponentsPage(FacesConfigEditor.this); - componentsPageID = addPage(componentsPage, null); - IFormPage othersPage = new OthersPage(FacesConfigEditor.this); - othersPageID = addPage(othersPage, null); - } - - sourcePage = new StructuredTextEditor(); - - sourcePage.setEditorPart(FacesConfigEditor.this); - - sourcePageId = addPage(sourcePage, FacesConfigEditor.this.getEditorInput()); - setPageText(sourcePageId, - EditorMessages.FacesConfigEditor_Source_TabName); - sourcePage.update(); - - // default active page to 0 - setActivePage(0); - - // execute deferred runnables - for (Runnable runnable : _deferredRunnables) - { - runnable.run(); - } - - // flag the fact that the regular editor pages have been added - _arePagesLoaded.set(true); - } catch (PartInitException e) { - EditorPlugin.getDefault().getLog().log( - new Status(IStatus.ERROR, EditorPlugin.getPluginId(), - IStatus.OK, e.getMessage() == null ? "" : e //$NON-NLS-1$ - .getMessage(), e)); - } - } - } - } - } - - /** - * Creates the pageflow page of the multi-page editor. - * @throws PartInitException - */ - protected void createAndAddPageflowPage() throws PartInitException { - pageflowPage = new PageflowEditor(this); - pageflowPageID = addPage(pageflowPage, getEditorInput()); - setPageText(pageflowPageID, - EditorMessages.FacesConfigEditor_Pageflow_TabName); - addPageActionRegistry(pageflowPage); - pageflowPage.getModelsTransform().setFacesConfig(getFacesConfig()); - pageflowPage.getModelsTransform().setPageflow( - pageflowPage.getPageflow()); - boolean fornew = pageflowPage.getModelsTransform() - .updatePageflowModelFromEMF(); - pageflowPage.setGraphicalViewerContents(pageflowPage.getPageflow()); - if (fornew) { - PageflowLayoutManager.getInstance().layoutPageflow( - pageflowPage.getPageflow()); - } - pageflowPage.getModelsTransform().setListenToNotify(true); - } - - /** - * TODO: this is used only for testing - * @return the page flow editor - */ - public PageflowEditor getPageflowPage() { - return pageflowPage; - } - - /** - * get the action's registry of sub pages. - * @param page - * - */ - protected void addPageActionRegistry(IEditorPart page) { - if (page != null) { - ActionRegistry pageActionRegisty = (ActionRegistry) page - .getAdapter(ActionRegistry.class); - if (pageActionRegisty != null) { - for (Iterator iter = pageActionRegisty.getActions(); iter - .hasNext();) { - getActionRegistry().registerAction((IAction) iter.next()); - } - } - } - } - - /** the editor's action registry */ - private ActionRegistry actionRegistry = null; - - /** - * Returns the action registry of this editor. - * - * @return - the action registry - */ - protected ActionRegistry getActionRegistry() { - if (null == actionRegistry) - actionRegistry = new ActionRegistry(); - - return actionRegistry; - } - - /** - * Returns the root object of the configuration model. - * - * @return the root object. Should not, but may return null. - */ - public FacesConfigType getFacesConfig() - { - FacesConfigArtifactEdit edit = _modelLoader.getEdit(); - if (edit != null) - { - return edit.getFacesConfig(); - } - return null; - } - - /* - * @see org.eclipse.ui.ISaveablePart#isDirty() - */ - public boolean isDirty() { - return ((BasicCommandStack) editingDomain.getCommandStack()) - .isSaveNeeded() - || super.isDirty(); - } - - /** - * This class listens for command stack changes of the pages contained in - * this editor and decides if the editor is dirty or not. - */ - private class MultiPageCommandStackListener implements CommandStackListener { - - /** the observed command stacks */ - private List commandStacks = new ArrayList(2); - - /** to get the editorpart from command stack */ - private HashMap mapEditorCommandStack = new HashMap(); - - private boolean saveLocation = false; - - /** - * Adds a <code>CommandStack</code> to observe. - * - * @param commandStack - * @param editor - */ - public void addCommandStack(CommandStack commandStack, - IEditorPart editor) { - if (commandStack == null) - return; - - if (mapEditorCommandStack.get(commandStack) == editor) - return; - - commandStacks.add(commandStack); - commandStack.addCommandStackListener(this); - mapEditorCommandStack.put(commandStack, editor); - } - - /** - * set the dirty status for the models of different editor - * - * @param editor - - * editor, e.g., pageflow or databinding page. - * @param dirty - - * true or false - */ - private void setEditorDirty(IEditorPart editor, boolean dirty) { - // do nothing - } - - /** the list of action ids that are to CommandStack actions */ - private List stackActionIDs = new ArrayList(); - - /** - * Updates the specified actions. - * - * @param actionIds - - * the list of ids of actions to update - */ - private void updateActions(List actionIds) { - for (Iterator ids = actionIds.iterator(); ids.hasNext();) { - IAction action = getActionRegistry().getAction(ids.next()); - if (null != action && action instanceof UpdateAction) { - ((UpdateAction) action).update(); - } - } - } - - /* - * (non-Javadoc) - * - * @see CommandStackListener#commandStackChanged(java.util.EventObject) - */ - public void commandStackChanged(EventObject event) { - // enable or disable the actions - updateActions(stackActionIDs); - if (((CommandStack) event.getSource()).isDirty()) { - // set the editor's model dirty status - setEditorDirty((IEditorPart) mapEditorCommandStack - .get(event.getSource()), true); - // at least one command stack is dirty, - // so the multi page editor is dirty too - setDirty(true); - } else { - // set the editor's model dirty status, if it is from not save - // location. - if (!saveLocation) { - setEditorDirty((IEditorPart) mapEditorCommandStack - .get(event.getSource()), true); - setDirty(true); - } else { - setDirty(false); - } - } - } - - /** the pageflow page editor's dirty state */ - private boolean isDirty = false; - - /** - * Changes the dirty state. - * - * @param dirty - - * dirty state - */ - public void setDirty(boolean dirty) { - if (isDirty != dirty) { - isDirty = dirty; - firePropertyChange(IEditorPart.PROP_DIRTY); - } - } - - /** - * Disposed the listener - */ - public void dispose() { - for (Iterator stacks = commandStacks.iterator(); stacks.hasNext();) { - ((CommandStack) stacks.next()).removeCommandStackListener(this); - } - commandStacks.clear(); - } - - /** - * Marks every observed command stack beeing saved. This method should - * be called whenever the editor/model was saved. - */ - public void markSaveLocations() { - saveLocation = true; - for (Iterator stacks = commandStacks.iterator(); stacks.hasNext();) { - CommandStack stack = (CommandStack) stacks.next(); - stack.markSaveLocation(); - } - saveLocation = false; - } - - /** - * Flushes every observed command stack and resets the save location to - * zero. - */ - public void flush() { - for (Iterator stacks = commandStacks.iterator(); stacks.hasNext();) { - CommandStack stack = (CommandStack) stacks.next(); - stack.flush(); - } - } - } - - /** the <code>CommandStackListener</code> */ - private MultiPageCommandStackListener multiPageCommandStackListener = null; - - /** - * Returns the global command stack listener. - * - * @return the <code>CommandStackListener</code> - */ - protected MultiPageCommandStackListener getMultiPageCommandStackListener() { - if (null == multiPageCommandStackListener) - multiPageCommandStackListener = new MultiPageCommandStackListener(); - - return multiPageCommandStackListener; - } - - /* - * @see org.eclipse.ui.ISaveablePart#doSave(org.eclipse.core.runtime.IProgressMonitor) - */ - public void doSave(IProgressMonitor monitor) { - // do the work within an operation because this is a long running - // activity that modifies the workbench - WorkspaceModifyOperation operation = new WorkspaceModifyOperation() { - public void execute(IProgressMonitor monitor_) { - try { - if (isWebProject && - _modelLoader.getEdit() != null) { - // modelResource.save(Collections.EMPTY_MAP); - _modelLoader.getEdit() - .getDeploymentDescriptorResource().save( - Collections.EMPTY_MAP); - IFile file = ((IFileEditorInput) getEditorInput()) - .getFile(); - pageflowPage.doSave(file, monitor_); - } - sourcePage.doSave(monitor_); - getMultiPageCommandStackListener().markSaveLocations(); - } catch (Exception e) { - EditorPlugin.getDefault().getLog().log( - new Status(IStatus.ERROR, EditorPlugin - .getPluginId(), IStatus.OK, - e.getMessage() == null ? "" : e //$NON-NLS-1$ - .getMessage(), e)); - } - } - }; - try { - // commit all pending changes in form pages - for (Iterator iter = pages.iterator(); iter.hasNext();) { - Object obj = iter.next(); - if (obj instanceof FormPage) { - ((FormPage) obj).doSave(monitor); - } - // else if (obj instanceof PageflowEditor) { - // ((PageflowEditor) obj).doSave(monitor); - // } - - } - operation.run(null);// .run(true, false, - // operation; - // runs the operation, and shows progress - // new ProgressMonitorDialog(); - - // refresh the necessary state - ((BasicCommandStack) editingDomain.getCommandStack()).saveIsDone(); - - editorDirtyStateChanged(); - } catch (Exception e) { - EditorPlugin.getDefault().getLog().log( - new Status(IStatus.ERROR, EditorPlugin.getPluginId(), - IStatus.OK, e.getMessage(), e)); - } - } - - public void doSaveAs() { - SaveAsDialog saveAsDialog = new SaveAsDialog(getSite().getShell()); - saveAsDialog.open(); - IPath path = saveAsDialog.getResult(); - if (path != null) { - IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path); - if (file != null) { - doSaveAs(URI.createPlatformResourceURI(file.getFullPath() - .toString()), new FileEditorInput(file)); - } - } - } - - /** - * @param uri - * @param editorInput - */ - protected void doSaveAs(URI uri, IEditorInput editorInput) { - editingDomain.getResourceSet().getResources().get(0) - .setURI(uri); - setInputWithNotify(editorInput); - setPartName(editorInput.getName()); - IProgressMonitor progressMonitor = getActionBars() - .getStatusLineManager() != null ? getActionBars() - .getStatusLineManager().getProgressMonitor() - : new NullProgressMonitor(); - doSave(progressMonitor); - } - - public boolean isSaveAsAllowed() { - return true; - } - - /** - * Returns the <code>TabbedPropertySheetPage</code> for this editor. - * - * @return - the <code>TabbedPropertySheetPage</code> - */ - protected IPropertySheetPage getPropertySheetPage() { - return new TabbedPropertySheetPage( - new ITabbedPropertySheetPageContributor() { - - public String getContributorId() { - return EDITOR_ID; - } - }); - } - - /** the delegating ZoomManager */ - private DelegatingZoomManager delegatingZoomManager = null; - - /** - * check whether the input is related with IFile. - * - * @param input - * @return - */ - private boolean isValidInput(IEditorInput input) { - if (input != null) { - IFile file = (IFile) input.getAdapter(IResource.class); - if (file != null) { - return true; - } - } - return false; - } - - /** - * Returns the <code>DelegatingZoomManager</code> for this editor. - * - * @return - the <code>DelegatingZoomManager</code> - */ - protected DelegatingZoomManager getDelegatingZoomManager() { - if (!isValidInput(getEditorInput()) || !isWebProject || !_addPagesTask.getArePagesLoaded()) { - return null; - } - if (null == delegatingZoomManager) { - delegatingZoomManager = new DelegatingZoomManager(); - delegatingZoomManager - .setCurrentZoomManager((ZoomManager) pageflowPage - .getAdapter(ZoomManager.class)); - } - return delegatingZoomManager; - } - - /** the delegating CommandStack */ - private DelegatingCommandStack delegatingCommandStack = null; - - /** - * Returns the <code>CommandStack</code> for this editor. - * - * @return - the <code>CommandStack</code> - */ - public DelegatingCommandStack getDelegatingCommandStack() { - if (null == delegatingCommandStack) { - delegatingCommandStack = new DelegatingCommandStack(); - } - return delegatingCommandStack; - } - - /* - * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) - */ - public Object getAdapter(Class adapter) { - if (adapter == IEditingDomainProvider.class) { - return new IEditingDomainProvider() { - public EditingDomain getEditingDomain() { - return editingDomain; - } - }; - } - if (adapter == EditingDomain.class) { - return editingDomain; - } - if (adapter == AdapterFactory.class) { - return adapterFactory; - } - if (adapter == IEditorPart.class) { - return getActiveEditor(); - } - - if (adapter == CommandStack.class) { - return getDelegatingCommandStack(); - } - if (adapter == ZoomManager.class) { - return getDelegatingZoomManager(); - } - - if (adapter == ActionRegistry.class) { - return getActionRegistry(); - } - if (adapter == IGotoMarker.class) { - return new IGotoMarker() { - public void gotoMarker(final IMarker marker) { - // this may be called on an editor open (i.e. double-click the Problems view) - // so ensure it runs safely with respect to the page load - _addPagesTask.pageSafeExecute(new Runnable() - { - public void run() - { - FacesConfigEditor.this.gotoMarker(marker); - } - }); - } - }; - } - if (adapter == StructuredTextEditor.class) { - return sourcePage; - } - - if (adapter == IContentOutlinePage.class) { - return getOutlinePage(); - } - - if (adapter == IPropertySheetPage.class) { - return getPropertySheetPage(); - } - - if (adapter == IProject.class) { - return getProject(); - } - - if (adapter == CTabFolder.class) { - return getContainer(); - } - - if (adapter == IOpenPage.class) { - return new IOpenPage() { - - public void setActiveEditorPage(String pageID) { - FacesConfigEditor.this.setActiveEditorPage(pageID); - - } - }; - } - - return super.getAdapter(adapter); - } - - private EMFCommandStackGEFAdapter sourceCommandStack; - - /** - * get or create the source page's GEF command stack based on its EMF - * command stack. - * - * @return - */ - private CommandStack getSourcePageCommandStack() { - if (sourceCommandStack == null) { - IDocument doc = sourcePage.getDocumentProvider().getDocument(getEditorInput()); - if (doc instanceof IStructuredDocument) { - IStructuredModel model = StructuredModelManager.getModelManager().getExistingModelForEdit(doc); - if (model == null) { - model = StructuredModelManager.getModelManager().getModelForEdit((IStructuredDocument) doc); - } - sourceCommandStack = new EMFCommandStackGEFAdapter( - (BasicCommandStack) model.getUndoManager() - .getCommandStack()); - } - else - { - EditorPlugin.getDefault().getLog().log( - new Status(IStatus.ERROR, EditorPlugin.getPluginId(), 0, - "Error getting undo stack for Faces Config editor. Undo may be disabled", //$NON-NLS-1$ - new Throwable())); - } - } - return sourceCommandStack; - } - - /** the list of action ids that are to CommandStack actions */ - // private List stackActionIDs = new ArrayList(); - /** the list of action ids that are editor actions */ - private List editorActionIDs = new ArrayList(); - - /** - * Adds an editor action to this editor. - * <p> - * Editor actions are actions that depend and work on the editor. - * - * @param action - - * the editor action - */ - protected void addEditorAction(EditorPartAction action) { - getActionRegistry().registerAction(action); - editorActionIDs.add(action.getId()); - } - - /** - * Creates different kinds of actions and registers them to the - * ActionRegistry. - */ - protected void createActions() { - // register save action - addEditorAction(new SaveAction(this)); - } - - /** - * Indicates that the current page has changed. - * <p> - * We update the DelegatingCommandStack, OutlineViewer and other things - * here. // - */ - protected void currentPageChanged() { - IEditorPart activeEditor = getActiveEditor(); - if (activeEditor == null) { - return; - } - - // update command stack - CommandStack cmdStack = null; - - if (activeEditor == pageflowPage) { - cmdStack = (CommandStack) activeEditor - .getAdapter(CommandStack.class); - } else if (activeEditor == sourcePage)// other page will delegate the - // GEF command stack to source - // page's. - { - cmdStack = this.getSourcePageCommandStack(); - } - - // Add command stacks - getMultiPageCommandStackListener().addCommandStack(cmdStack, - activeEditor); - getDelegatingCommandStack().setCurrentCommandStack(cmdStack); - - // enable or disable the actions - // updateActions(stackActionIDs); - - // update zoom actions - ZoomManager zoomManager = null; - zoomManager = (ZoomManager) activeEditor.getAdapter(ZoomManager.class); - - if (zoomManager != null) { - getDelegatingZoomManager().setCurrentZoomManager(zoomManager); - } - - IEditorActionBarContributor contributor = getEditorSite() - .getActionBarContributor(); - if (contributor != null - && contributor instanceof FacesConfigActionBarContributor) { - ((FacesConfigActionBarContributor) contributor) - .setActivePage(activeEditor); - } - } - - /* - * (non-Javadoc) - * - * @see MultiPageEditorPart#pageChange(int) - */ - protected void pageChange(int newPageIndex) { - super.pageChange(newPageIndex); - // getActionBarContributor().setActivePage(getActiveEditor()); - // refresh content depending on current page - currentPageChanged(); - } - - public void dispose() - { - // signal that we have been disposed - // do this before anything else - _isDisposed = true; - _modelLoader.dispose(); - - ResourcesPlugin.getWorkspace().removeResourceChangeListener( - resourceChangeListener); - - adapterFactory.dispose(); - - if (this.outlinePage != null) { - outlinePage.dispose(); - } - - super.dispose(); - } - - /** - * get the project of the faces config file that the editor is working on. - * - * @return IProject - */ - public IProject getProject() { - if (currentProject == null) { - if (_modelLoader.getEdit() != null) { - IFile file = _modelLoader.getEdit().getFile(); - if (file != null) - currentProject = file.getProject(); - } - } - return currentProject; - } - - public EditingDomain getEditingDomain() { - return editingDomain; - } - - /** - * Returns the <code>IContentOutlinePage</code> for this editor. - * - * @return - the <code>IContentOutlinePage</code> - */ - protected IContentOutlinePage getOutlinePage() { - if (null == outlinePage) { - outlinePage = new MultiPageEditorOutlinePage(); - } - return outlinePage; - } - - public void addSelectionChangedListener(ISelectionChangedListener listener) { - selectionChangedListeners.add(listener); - } - - public ISelection getSelection() { - return editorSelection; - } - - public void removeSelectionChangedListener( - ISelectionChangedListener listener) { - selectionChangedListeners.remove(listener); - } - - public void setSelection(ISelection selection) { - editorSelection = selection; - for (Iterator listeners = selectionChangedListeners.iterator(); listeners - .hasNext();) { - ISelectionChangedListener listener = (ISelectionChangedListener) listeners - .next(); - listener - .selectionChanged(new SelectionChangedEvent(this, selection)); - } - } - - private void gotoMarker(IMarker marker) { - setActivePage(sourcePageId); - IDE.gotoMarker(this.sourcePage, marker); - } - - /** - * FIXME: this is used only for testing. Should isolate better - * @return the action bar - */ - public FacesConfigActionBarContributor getActionBarContributor() { - return (FacesConfigActionBarContributor) getEditorSite() - .getActionBarContributor(); - } - - private IActionBars getActionBars() { - return getActionBarContributor().getActionBars(); - } - - /** - * Shows a dialog that asks if conflicting changes should be discarded. - * @return the user's response. - */ - protected boolean handleDirtyConflict() { - return MessageDialog - .openQuestion( - getSite().getShell(), - EditorMessages.FacesConfigEditor_ErrorHandlingUndoConflicts_DialogTitle, - EditorMessages.FacesConfigEditor_ErrorHandlingUndoConflicts_DialogMessage); - } - - /** - * Handles what to do with changed resources on activation. - * - * @generated - */ - protected void handleChangedResources() { - if (!changedResources.isEmpty() - && (!isDirty() || handleDirtyConflict())) { - editingDomain.getCommandStack().flush(); - - for (Iterator i = changedResources.iterator(); i.hasNext();) { - Resource resource = (Resource) i.next(); - if (resource.isLoaded()) { - resource.unload(); - try { - resource.load(Collections.EMPTY_MAP); - } catch (IOException exception) { - EditorPlugin.getDefault().getLog().log( - new Status(IStatus.ERROR, EditorPlugin - .getPluginId(), IStatus.OK, exception - .getMessage() == null ? "" : exception //$NON-NLS-1$ - .getMessage(), exception)); - } - } - } - } - } - - /** - * TODO this is used only for testing. Should be able to remove if we - * go to true automated UI testing - * @param pageID - */ - public void setActiveEditorPage(String pageID) { - if (pageID.equals(PageflowEditor.PAGE_ID)) { - setActivePage(pageflowPageID); - } else if (pageID.equals(ManagedBeanPage.PAGE_ID)) { - setActivePage(managedBeanPageID); - } else if (pageID.equals(ComponentsPage.PAGE_ID)) { - setActivePage(componentsPageID); - } else if (pageID.equals(OthersPage.PAGE_ID)) { - setActivePage(othersPageID); - } - } - - private boolean matches(IEditorInput input) { - final IResource file = (IResource) input.getAdapter(IResource.class); - boolean hasWebFacet = false; - boolean hasJSFFacet = false; - - if (file != null) { - final IProject project = file.getProject(); - - if (project != null) { - try { - final IFacetedProject facetedProject = ProjectFacetsManager - .create(project); - - if (facetedProject != null) { - final Set facets = facetedProject.getProjectFacets(); - - for (final Iterator it = facets.iterator(); it - .hasNext();) { - final IProjectFacetVersion version = (IProjectFacetVersion) it - .next(); - - IProjectFacet facet = version.getProjectFacet(); - if (IJSFCoreConstants.JSF_CORE_FACET_ID.equals(facet.getId())) { - hasJSFFacet = true; - } else if ("jst.web".equals(facet.getId())) { //$NON-NLS-1$ - hasWebFacet = true; - } - } - } - } catch (CoreException ex) { - EditorPlugin.getDefault().getLog().log( - new Status(IStatus.ERROR, EditorPlugin - .getPluginId(), IStatus.OK, - ex.getMessage() == null ? "" : ex //$NON-NLS-1$ - .getMessage(), ex)); - } - } - } - - return hasWebFacet && hasJSFFacet; - } - - /** - * DANGER! This call is for testing only! Should not be used, - * even internally, by production code. - * @param timeoutMs the time to wait in milliseconds - * @throws InterruptedException - */ - public void doPageLoad(long timeoutMs) throws InterruptedException - { - _modelLoader.waitForLoad(timeoutMs); - _addPagesTask.doRun(_modelLoader.getEdit()); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/IFacesConfigConstants.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/IFacesConfigConstants.java deleted file mode 100644 index bb72553da..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/IFacesConfigConstants.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui; - -/** - * @author jchoi - * @version - */ -public interface IFacesConfigConstants { - - public static final String FACES_CONFIG = "faces-config"; - - public static final String MANAGED_PROPERTY = "managed-property"; - - public static final String VALUE = "value"; - - public static final String NULL_VALUE = "null-value"; - - public static final String MAP_ENTRIES = "map-entries"; - - public static final String MAP_ENTRY = "map-entry"; - - public static final String LIST_ENTRIES = "list-entries"; - - public static final String NAVIGATION_RULE = "navigation-rule"; - - public static final String COMPONENT_SUPER_CLASS = "javax.faces.component.UIComponent"; - - public static final String RENDER_KIT_SUPER_CLASS = "javax.faces.render.RenderKit"; - - public static final String CONVERTER_INTERFACE = "javax.faces.convert.Converter"; - - public static final String VALIDATOR_INTERFACE = "javax.faces.validator.Validator"; - - public static final String RENDERER_SUPER_CLASS = "javax.faces.render.Renderer"; - - public static final String ACTION_LISTENER_INTERFACE = "javax.faces.event.ActionListener"; - - public static final String NAVIGATION_HANDLE_SUPER_CLASS = "javax.faces.application.NavigationHandler"; - - public static final String PROPERTY_RESOLVER_SUPER_CLASS = "javax.faces.el.PropertyResolver"; - - public static final String STATE_MANAGER_SUPER_CLASS = "javax.faces.application.StateManager"; - - public static final String VARIABLE_RESOLVER_SUPER_CLASS = "javax.faces.el.VariableResolver"; - - public static final String VIEW_HANDLER_SUPER_CLASS = "javax.faces.application.ViewHandler"; - - public static final String APPLICATION_FACTORY_SUPER_CLASS = "javax.faces.application.ApplicationFactory"; - - public static final String FACES_CONTEXT_FACTORY_SUPER_CLASS = "javax.faces.context.FacesContextFactory"; - - public static final String LIFECYCLE_FACTORY_SUPER_CLASS = "javax.faces.lifecycle.LifecycleFactory"; - - public static final String RENDER_KIT_FACTORY_SUPER_CLASS = "javax.faces.render.RenderKitFactory"; - - public static final String PHASE_LISTENER_INTERFACE = "javax.faces.event.PhaseListener"; - - public static final String MANAGED_BEAN_SCOPE_APPLICATION = "application"; - - public static final String MANAGED_BEAN_SCOPE_SESSION = "session"; - - public static final String MANAGED_BEAN_SCOPE_REQUEST = "request"; - - public static final String MANAGED_BEAN_SCOPE_NONE = "none"; - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/INestedActionContributor.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/INestedActionContributor.java deleted file mode 100644 index f50fc573a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/INestedActionContributor.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.jst.jsf.facesconfig.ui; - -/** - * The nested action contributor should be able to update its actions as - * required. - */ -public interface INestedActionContributor { - void update(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/ModelLoader.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/ModelLoader.java deleted file mode 100644 index 417b949b3..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/ModelLoader.java +++ /dev/null @@ -1,215 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.jst.jsf.facesconfig.ui.util.WebrootUtil; -import org.eclipse.jst.jsf.facesconfig.util.FacesConfigArtifactEdit; -import org.eclipse.ui.PlatformUI; - -/** - * Centralizes logic to load the faces config model off of the UI thread for - * the FacesConfig Editor. - * - * Also encapsulates the lifecycle for the instance of the faces artifact - * created for its editor. All creation, access and destruction of the artifact - * should be centralized through this class - * - * @author cbateman - * - */ -class ModelLoader -{ - private FacesConfigArtifactEdit _edit; - private Job _loadModelJob; - private CountDownLatch _modelLoaded = new CountDownLatch(1); - - /** - * @return the artifact edit or null if not loaded. Should only be called - * after load() is called and has executed its callback - */ - public synchronized FacesConfigArtifactEdit getEdit() { - return _edit; - } - - private synchronized void setEdit(FacesConfigArtifactEdit edit) - { - _edit = edit; - } - - void waitForLoad(long timeoutMs) throws InterruptedException - { - _modelLoaded.await(timeoutMs, TimeUnit.MILLISECONDS); - } - - /** - * Dispose of the model and any unfinished loading operations - * - * Must be run on the UI thread. - */ - public synchronized void dispose() - { - assertOnDisplayThread(); - - // if the load model job has not completed, cancel it - if (_loadModelJob != null - && _loadModelJob.getResult() == null) - { - _loadModelJob.cancel(); - } - - if (_edit != null) - { - _edit.dispose(); - //System.out.println("FacesConfigEditor.dispose(): isDisposed == "+_edit.isDisposed()); - } - } - - /** - * Load the model file located by path in project. Must be called from the UI thread. - * - * Method does not block. - * - * @param project - * @param path - * @param isWebProject - * @param signalComplete to be asyncExec'd on the UI thread when the model is loaded - */ - public void load(final IProject project, final IPath path, final boolean isWebProject, final ModelLoaderComplete signalComplete) - { - assertOnDisplayThread(); - _loadModelJob = new ModelLoaderJob(project, path, isWebProject, signalComplete); - _loadModelJob.schedule(); - } - - private class ModelLoaderJob extends Job - { - private final IProject _project; - private final IPath _path; - private final ModelLoaderComplete _runnable; - private final boolean _isWebProject; - - ModelLoaderJob(final IProject project, final IPath path, final boolean isWebProject, final ModelLoaderComplete signalComplete) - { - super(EditorMessages.ModelLoader_LoadingModelJobName); - _project = project; - _path = path; - _runnable = signalComplete; - _isWebProject = isWebProject; - } - - @Override - protected IStatus run(IProgressMonitor monitor) - { - FacesConfigArtifactEdit artifactEdit = loadModel(_project, _path); - - // synchrnoize on the ModelLoader. Ensure that any call to dispose() - // that occurs before we set the edit is done atomically. - synchronized(ModelLoader.this) - { - // only bother with this if the task hasn't been signalled for cancel - if (!monitor.isCanceled()) - { - setEdit(artifactEdit); - - _runnable.setFacesConfigArtifactEdit(artifactEdit); - - // finish as quickly possible; we are holding the ModelLoader - // lock so we must ensure that we don't block. - // NEVER USE syncExec here. - PlatformUI.getWorkbench().getDisplay().asyncExec(_runnable); - } - // if we were cancelled, then dispose of the artifact edit - else - { - if (artifactEdit != null) - { - artifactEdit.dispose(); - } - } - } - - // signal that we are done loading - _modelLoaded.countDown(); - return Status.OK_STATUS; - } - - /** - * Loads the configuration model from the given path. - * - */ - private FacesConfigArtifactEdit loadModel(IProject project, IPath modelPath) - { - if (_isWebProject) - { - IFolder webContentFolder = WebrootUtil.getWebContentFolder(project); - Assert - .isTrue(webContentFolder != null - && webContentFolder.exists()); - - IPath relativePath = modelPath; - if (webContentFolder.getFullPath().isPrefixOf(modelPath)) { - relativePath = modelPath.removeFirstSegments(webContentFolder - .getFullPath().segmentCount()); - } - - - return FacesConfigArtifactEdit - .getFacesConfigArtifactEditForWrite(project, relativePath - .toString()); - } - - return null; - } - } - - abstract static class ModelLoaderComplete implements Runnable - { - private FacesConfigArtifactEdit _edit; - - private void setFacesConfigArtifactEdit(FacesConfigArtifactEdit edit) - { - _edit = edit; - } - - public final void run() - { - assertOnDisplayThread(); - doRun(_edit); - } - - /** - * Called by the runnable. Implementer should _not_ cache the edit variable - * edit may be null - * - * @param edit - */ - protected abstract void doRun(FacesConfigArtifactEdit edit); - } - - private static void assertOnDisplayThread() - { - if (Thread.currentThread() != PlatformUI.getWorkbench().getDisplay().getThread()) - { - throw new IllegalStateException("ModelLoaderComplete must be called on the UI thread"); //$NON-NLS-1$ - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/MultiPageEditorOutlinePage.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/MultiPageEditorOutlinePage.java deleted file mode 100644 index 90e5cae8d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/MultiPageEditorOutlinePage.java +++ /dev/null @@ -1,706 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -import org.eclipse.core.runtime.ListenerList; -import org.eclipse.core.runtime.SafeRunner; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.util.SafeRunnable; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jst.jsf.common.ui.internal.logging.Logger; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CTabFolder; -import org.eclipse.swt.custom.CTabItem; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.SubActionBars; -import org.eclipse.ui.part.EditorPart; -import org.eclipse.ui.part.IPage; -import org.eclipse.ui.part.IPageBookViewPage; -import org.eclipse.ui.part.IPageSite; -import org.eclipse.ui.part.MessagePage; -import org.eclipse.ui.part.MultiPageEditorPart; -import org.eclipse.ui.part.Page; -import org.eclipse.ui.part.PageBook; -import org.eclipse.ui.views.contentoutline.IContentOutlinePage; - -/** - * @author Xiao-guang Zhang - * - * The outline page class for mulitPage Editorpart. - */ -public class MultiPageEditorOutlinePage extends Page implements - IContentOutlinePage, SelectionListener { - /** log instance */ - private static final Logger log = EditorPlugin - .getLogger(MultiPageEditorOutlinePage.class); - - /** - * Selection change listeners. - */ - private ListenerList selectionChangedListeners = new ListenerList(ListenerList.IDENTITY); - - /** the pagebook */ - private PageBook pageBook = null; - - /** - * Selection change listener to listen for page selection changes - */ - private ISelectionChangedListener selectionChangedListener = new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - pageSelectionChanged(event); - } - }; - - /** - * A data structure used to store the information about a single page within - * a MultiPageEditorOutlinePage - */ - protected static class PageRec { - - /** - * The part including editorpart, or Control - */ - public IWorkbenchPart part; - - /** - * The page. - */ - public IPage page; - - /** - * The page's action bars - */ - public SubActionBars subActionBars; - - /** - * Creates a new page record initialized to the given part and page. - * - * @param part - * @param page - */ - public PageRec(IWorkbenchPart part, IPage page) { - this.part = part; - this.page = page; - } - - /** - * Disposes of this page record by <code>null</code>ing its fields. - */ - public void dispose() { - part = null; - page = null; - } - } - - /** - * The page record for the default page. - */ - private PageRec defaultPageRec; - - /** - * Map from parts to part records (key type: <code>IWorkbenchPart</code>; - * value type: <code>PartRec</code>). - */ - private Map mapPartToRec = new HashMap(); - - /** - * Map from pages to view sites Note that view sites were not added to page - * recs to avoid breaking binary compatibility with previous builds - */ - private Map mapPageToSite = new HashMap(); - - /** - * The page rec which provided the current page or <code>null</code> - */ - private PageRec activeRec; - - /** - * the container composite control of MutliPageEditorPart - */ - private CTabFolder tabFolder; - - /** - * Creates a new MultiPageEditorOutlinePage instance. - * - * - */ - public MultiPageEditorOutlinePage() { - super(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.part.Page#createControl(org.eclipse.swt.widgets.Composite) - */ - public void createControl(Composite parent) { - // pagebook - pageBook = new PageBook(parent, SWT.NONE); - - // Create the default page rec. - IPage defaultPage = createDefaultPage(pageBook); - defaultPageRec = new PageRec(null, defaultPage); - preparePage(defaultPageRec); - - // Show the default page - showPageRec(defaultPageRec); - - // get the tab control and add the page selection listener. - if (getContainerForMultiPageEditorPart() != null) { - getContainerForMultiPageEditorPart().addSelectionListener(this); - } - - // show the activate part page. - showBootstrapPart(); - } - - /* - * (non-Javadoc) - * - * @see Page#dispose() - */ - public void dispose() { - // Deref all of the pages. - activeRec = null; - if (defaultPageRec != null) { - // check for null since the default page may not have - // been created (ex. perspective never visible) - defaultPageRec.page.dispose(); - defaultPageRec = null; - } - Map clone = (Map) ((HashMap) mapPartToRec).clone(); - Iterator iterator = clone.values().iterator(); - while (iterator.hasNext()) { - PageRec rec = (PageRec) iterator.next(); - removePage(rec); - } - - // important: always call super implementation of dispose - super.dispose(); - } - - /** - * Creates and returns the default page for this view. - * - * @param book - - * the pagebook control - * @return - the default page - */ - protected IPage createDefaultPage(PageBook book) { - // Message to show on the default page - String defaultText = EditorMessages.MultiPageEditorOutlinePage_noOutline; - - MessagePage page = new MessagePage(); - initPage(page); - page.createControl(book); - page.setMessage(defaultText); - return page; - } - - /** - * Prepares the page in the given page rec for use in this view. - * - * @param rec - - * the page rec - */ - private void preparePage(PageRec rec) { - IPageSite site = null; - - if (!doesPageExist(rec.page)) { - if (rec.page instanceof IPageBookViewPage) { - site = ((IPageBookViewPage) rec.page).getSite(); - } - if (site == null) { - // We will create a site for our use - site = new SubPageSite(getSite()); - } - mapPageToSite.put(rec.page, site); - - rec.subActionBars = (SubActionBars) site.getActionBars(); - // rec.subActionBars.addPropertyChangeListener(actionBarPropListener); - // for backward compability with IPage - rec.page.setActionBars(rec.subActionBars); - - } else { - site = (IPageSite) mapPageToSite.get(rec.page); - rec.subActionBars = (SubActionBars) site.getActionBars(); - } - } - - /** - * Returns the currently visible page for this view or <code>null</code> - * if no page is currently visible. - * - * @return the currently visible page - */ - public IPage getCurrentPage() { - if (activeRec == null) - return null; - return activeRec.page; - } - - /** - * Returns the view site for the given page of this view. - * - * @param page - * the page - * @return the corresponding site, or <code>null</code> if not found - */ - protected SubPageSite getPageSite(IPage page) { - return (SubPageSite) mapPageToSite.get(page); - } - - /** - * Shows page contained in the given page record in this view. The page - * record must be one from this pagebook view. - * <p> - * The <code>PageBookView</code> implementation of this method asks the - * pagebook control to show the given page's control, and records that the - * given page is now current. Subclasses may extend. - * </p> - * - * @param pageRec - * the page record containing the page to show - */ - protected void showPageRec(PageRec pageRec) { - IPageSite pageSite = getPageSite(pageRec.page); - ISelectionProvider provider = pageSite.getSelectionProvider(); - if (provider == null && (pageRec.page instanceof IContentOutlinePage)) { - // This means that the page did not set a provider during its - // initialization - // so for backward compatibility we will set the page itself as the - // provider. - pageSite.setSelectionProvider((IContentOutlinePage) pageRec.page); - } - - // If already showing do nothing - if (activeRec == pageRec) { - return; - } - // If the page is the same, just set activeRec to pageRec - if (activeRec != null && pageRec != null - && activeRec.page == pageRec.page) { - activeRec = pageRec; - return; - } - - // Hide old page. - if (activeRec != null) { - activeRec.subActionBars.deactivate(); - // remove our selection listener - provider = ((SubPageSite) mapPageToSite.get(activeRec.page)) - .getSelectionProvider(); - if (provider != null) { - provider - .removeSelectionChangedListener(selectionChangedListener); - } - } - // Show new page. - activeRec = pageRec; - Control pageControl = activeRec.page.getControl(); - if (pageControl != null && !pageControl.isDisposed()) { - // Verify that the page control is not disposed - // If we are closing, it may have already been disposed - pageBook.showPage(pageControl); - activeRec.subActionBars.activate(); - refreshGlobalActionHandlers(); - // add our selection listener - provider = ((SubPageSite) mapPageToSite.get(activeRec.page)) - .getSelectionProvider(); - if (provider != null) { - provider.addSelectionChangedListener(selectionChangedListener); - } - // Update action bars. - getSite().getActionBars().updateActionBars(); - } - } - - /** - * Refreshes the global actions for the active page. - */ - private void refreshGlobalActionHandlers() { - // Clear old actions. - IActionBars bars = getSite().getActionBars(); - bars.clearGlobalActionHandlers(); - - // Set new actions. - Map newActionHandlers = activeRec.subActionBars - .getGlobalActionHandlers(); - if (newActionHandlers != null) { - Set keys = newActionHandlers.entrySet(); - Iterator iter = keys.iterator(); - while (iter.hasNext()) { - Map.Entry entry = (Map.Entry) iter.next(); - bars.setGlobalActionHandler((String) entry.getKey(), - (IAction) entry.getValue()); - } - } - } - - /** - * Creates a page for a given part. Adds it to the pagebook but does not - * show it. - * - * @param part - * The part we are making a page for. - * @return IWorkbenchPart - */ - private PageRec createPage(IWorkbenchPart part) { - PageRec rec = doCreatePage(part); - if (rec != null) { - mapPartToRec.put(part, rec); - preparePage(rec); - } - return rec; - } - - /* - * (non-Javadoc) Method declared on PageBookView. - */ - protected PageRec doCreatePage(IWorkbenchPart part) { - // Try to get an outline page. - Object obj = part.getAdapter(IContentOutlinePage.class); - if (obj instanceof IContentOutlinePage) { - IContentOutlinePage page = (IContentOutlinePage) obj; - if (page instanceof IPageBookViewPage) { - initPage((IPageBookViewPage) page); - } - page.createControl(getPageBook()); - return new PageRec(part, page); - } - // There is no content outline - return null; - } - - /** - * Returns the pagebook control for this view. - * - * @return the pagebook control, or <code>null</code> if not initialized - */ - protected PageBook getPageBook() { - return pageBook; - } - - /** - * Returns the page record for the given part. - * - * @param part - * the part - * @return the corresponding page record, or <code>null</code> if not - * found - */ - protected PageRec getPageRec(Object part) { - return (PageRec) mapPartToRec.get(part); - } - - /** - * Initializes the given page with a page site. - * <p> - * Subclasses should call this method after the page is created but before - * creating its controls. - * </p> - * <p> - * Subclasses may override - * </p> - * - * @param page - * The page to initialize - */ - protected void initPage(IPageBookViewPage page) { - try { - page.init(new SubPageSite(getSite())); - } catch (PartInitException e) { - log.error(e.getMessage()); - } - } - - /** - * Shows a page for the active workbench part. - */ - private void showBootstrapPart() { - IWorkbenchPart part = getBootstrapPart(); - if (part != null) { - partActivated(part); - } - } - - /** - * Returns the active, important workbench part for this view. - * - * @return the active important part, or <code>null</code> if none - */ - private IWorkbenchPart getBootstrapPart() { - IWorkbenchPage page = getSite().getPage(); - if (page != null - && page.getActiveEditor() instanceof MultiPageEditorPart) { - // get active editor of mutli-page editor. - return (IWorkbenchPart) page.getActiveEditor().getAdapter( - IEditorPart.class); - } - return null; - } - - /** - * This method shows the page when the given part is activated. Subclasses - * may extend. - */ - private void partActivated(IWorkbenchPart part) { - // Is this an important part? If not just return. - if (!isImportant(part)) { - return; - } - - // Create a page for the part. - PageRec rec = getPageRec(part); - if (rec == null) { - rec = createPage(part); - } - - // Show the page. - if (rec != null) { - showPageRec(rec); - } else { - showPageRec(defaultPageRec); - } - } - - /** - * Returns true if the page has already been created. - * - * @param page - * the page to test - * @return true if this page has already been created. - */ - private boolean doesPageExist(IPage page) { - return mapPageToSite.containsKey(page); - } - - /** - * Returns whether the given part should be added to this view. - * - * @param part - * the input part - * @return <code>true</code> if the part is relevant, and - * <code>false</code> otherwise - */ - protected boolean isImportant(IWorkbenchPart part) { - // We only care about editors - return (part instanceof IEditorPart); - } - - /** - * get the composite control (Container) of source MultiPageEditorPart - * - * @return - the composite control (Container) - */ - private CTabFolder getContainerForMultiPageEditorPart() { - if (null == tabFolder) { - tabFolder = ((CTabFolder) (getSite().getPage().getActiveEditor() - .getAdapter(CTabFolder.class))); - } - return tabFolder; - } - - /** - * Removes a page record. If it is the last reference to the page dispose of - * it - otherwise just decrement the reference count. - * - * @param rec - */ - private void removePage(PageRec rec) { - mapPartToRec.remove(rec.part); - IPageSite site = (IPageSite) mapPageToSite.remove(rec.page); - - if (rec.subActionBars != null) { - rec.subActionBars.dispose(); - } - - Control control = rec.page.getControl(); - if (control != null && !control.isDisposed()) { - // Dispose the page's control so pages don't have to do this in - // their - // dispose method. - // The page's control is a child of this view's control so if this - // view - // is closed, the page's control will already be disposed. - control.dispose(); - } - - if (site instanceof SubPageSite) { - ((SubPageSite) site).dispose(); - } - - // free the page - doDestroyPage(rec.part, rec); - } - - /** - * Destroys a page in the pagebook for a particular part. - * - * @param part - * the input part - * @param rec - * a page record for the part - */ - protected void doDestroyPage(IWorkbenchPart part, PageRec rec) { - IContentOutlinePage page = (IContentOutlinePage) rec.page; - page.dispose(); - rec.dispose(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.part.Page#getControl() - */ - public Control getControl() { - return pageBook; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.part.Page#setFocus() - */ - public void setFocus() { - if (getControl() != null) { - getControl().setFocus(); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ISelectionProvider#addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) - */ - public void addSelectionChangedListener(ISelectionChangedListener listener) { - selectionChangedListeners.add(listener); - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection() - */ - public ISelection getSelection() { - // get the selection provider from the current page - IPage currentPage = getCurrentPage(); - // during workbench startup we may be in a state when - // there is no current page - if (currentPage == null) { - return StructuredSelection.EMPTY; - } - IPageSite site = getPageSite(currentPage); - if (site == null) { - return StructuredSelection.EMPTY; - } - ISelectionProvider selProvider = site.getSelectionProvider(); - if (selProvider != null) { - return selProvider.getSelection(); - } - return StructuredSelection.EMPTY; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ISelectionProvider#removeSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) - */ - public void removeSelectionChangedListener( - ISelectionChangedListener listener) { - selectionChangedListeners.remove(listener); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection) - */ - public void setSelection(ISelection selection) { - // get the selection provider from the current page - IPage currentPage = getCurrentPage(); - // during workbench startup we may be in a state when - // there is no current page - if (currentPage == null) { - return; - } - IPageSite site = getPageSite(currentPage); - if (site == null) { - return; - } - ISelectionProvider selProvider = site.getSelectionProvider(); - // and set its selection - if (selProvider != null) { - selProvider.setSelection(selection); - } - } - - /** - * The selection has changed. Process the event. - * - * @param event - */ - public void pageSelectionChanged(final SelectionChangedEvent event) { - // pass on the notification to listeners - Object[] listeners = selectionChangedListeners.getListeners(); - for (int i = 0; i < listeners.length; ++i) { - final ISelectionChangedListener l = (ISelectionChangedListener) listeners[i]; - SafeRunner.run(new SafeRunnable() { - public void run() { - l.selectionChanged(event); - } - }); - } - - } - - /* - * (non-Javadoc) - * - * @see SelectionListener#widgetSelected(SelectionEvent) - */ - public void widgetSelected(SelectionEvent e) { - EditorPart part = (EditorPart) ((CTabItem) e.item).getData(); - - if (part != null) { - partActivated(part); - } - } - - /* - * (non-Javadoc) - * - * @see SelectionListener#widgetDefaultSelected(SelectionEvent) - */ - public void widgetDefaultSelected(SelectionEvent e) { - // do nothing: no handling of default selected event - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/MyEditingDomainActionContributor.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/MyEditingDomainActionContributor.java deleted file mode 100644 index 93eb8e44e..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/MyEditingDomainActionContributor.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.jst.jsf.facesconfig.ui; - -import org.eclipse.emf.edit.domain.IEditingDomainProvider; -import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.actions.ActionFactory; - -/** - * The action contributor for form based page. - * - * @author hmeng - * - */ -public class MyEditingDomainActionContributor extends - EditingDomainActionBarContributor implements INestedActionContributor { - public MyEditingDomainActionContributor() { - super(); - } - - public void setActiveEditor(IEditorPart part) { - if (getActiveEditor() != null) { - deactivate(); - } - super.setActiveEditor(part); - IActionBars actionBars = getActionBars(); - actionBars.clearGlobalActionHandlers(); - if (part instanceof IEditingDomainProvider) { - actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), - deleteAction); - actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), - undoAction); - actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), - redoAction); - // actionBars.setGlobalActionHandler(ActionFactory.CUT.getId(), - // cutAction); - // actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), - // copyAction); - // actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), - // pasteAction); - activate(); - } - } - - public void update() { - if (getActiveEditor() instanceof IEditingDomainProvider) { - super.update(); - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/SubPageSite.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/SubPageSite.java deleted file mode 100644 index 9b459e85e..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/SubPageSite.java +++ /dev/null @@ -1,167 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.SubActionBars; -import org.eclipse.ui.part.IPageSite; - -/** - * - * This implementation of <code>IPageSite</code> provides a site for a sub - * page within a <code>Page</code>. Most methods are forwarded to the parent - * page's site. - * - * @author Xiao-guang Zhang - */ -public class SubPageSite implements IPageSite { - - /** - * The "parent" Page site - */ - private IPageSite parentSite; - - /** - * A selection provider set by the page. Value is <code>null</code> until - * set. - */ - private ISelectionProvider selectionProvider; - - /** - * The action bars for this site - */ - private SubActionBars subActionBars; - - /** - * The list of menu extender for each registered menu. - */ -// private ArrayList menuExtenders; - - /** - * Creates a new sub page site of the given parent page site. - * - * @param parentSite - * the parent view site - */ - public SubPageSite(IPageSite parentSite) { - Assert.isNotNull(parentSite); - this.parentSite = parentSite; - subActionBars = new SubActionBars(this.parentSite.getActionBars()); - } - - /** - * Disposes of the menu extender contributions. - */ - protected void dispose() { - // if (menuExtenders != null) { - // for (int i = 0; i < menuExtenders.size(); i++) { - // ((PopupMenuExtender) menuExtenders.get(i)).dispose(); - // } - // menuExtenders = null; - // } - subActionBars.dispose(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.part.IPageSite#registerContextMenu(java.lang.String, - * org.eclipse.jface.action.MenuManager, - * org.eclipse.jface.viewers.ISelectionProvider) - */ - public void registerContextMenu(String menuId, MenuManager menuManager, - ISelectionProvider selectionProvider1) { - - parentSite.registerContextMenu(menuId, menuManager, selectionProvider1); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.part.IPageSite#getActionBars() - */ - public IActionBars getActionBars() { - return subActionBars; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IWorkbenchSite#getPage() - */ - public IWorkbenchPage getPage() { - return parentSite.getPage(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IWorkbenchSite#getSelectionProvider() - */ - public ISelectionProvider getSelectionProvider() { - return selectionProvider; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IWorkbenchSite#getShell() - */ - public Shell getShell() { - return parentSite.getShell(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IWorkbenchSite#getWorkbenchWindow() - */ - public IWorkbenchWindow getWorkbenchWindow() { - return parentSite.getWorkbenchWindow(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IWorkbenchSite#setSelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) - */ - public void setSelectionProvider(ISelectionProvider provider) { - selectionProvider = provider; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) - */ - public Object getAdapter(Class adapter) { - return parentSite.getAdapter(adapter); - } - - public Object getService(Class api) { - // TODO Auto-generated method stub - return null; - } - - public boolean hasService(Class api) { - // TODO Auto-generated method stub - return false; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/AddEditAttributeDialog.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/AddEditAttributeDialog.java deleted file mode 100644 index 055fffc67..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/AddEditAttributeDialog.java +++ /dev/null @@ -1,238 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.dialog; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.ClassButtonDialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.LayoutUtil; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.StringDialogField; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.TabFolder; -import org.eclipse.swt.widgets.TabItem; - -/** - * The dialog is for adding and editing attribute. - * - * @author sfshi - * - */ -public class AddEditAttributeDialog extends Dialog { - - private static final int MIN_DIALOG_WIDTH = 300; - - private StringDialogField attributeNameField; - - private ClassButtonDialogField attributeClassField; - - private StringDialogField defaultValueField; - - private StringDialogField suggestedValueField; - - private IProject project; - - private String attributeName; - - private String attributeClass; - - private String defaultValue; - - private String suggestedValue; - - private boolean isNew; - - public AddEditAttributeDialog(Shell parentShell, boolean isNew) { - super(parentShell); - this.isNew = isNew; - } - - /** - * - * @param parentShell - * @param attributeName - * @param attributeClass - * @param defaultValue - * @param suggestedValue - */ - public AddEditAttributeDialog(Shell parentShell, String attributeName, - String attributeClass, String defaultValue, String suggestedValue) { - super(parentShell); - this.attributeName = attributeName; - this.attributeClass = attributeClass; - this.defaultValue = defaultValue; - this.suggestedValue = suggestedValue; - this.isNew = false; - } - - /* - * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) - */ - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - if (isNew) - newShell.setText(EditorMessages.AttributeSection_Dialog_Title_Add); - else - newShell - .setText(EditorMessages.AttributeSection_Dialog_Title_Edit); - } - - /* - * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) - */ - protected Control createDialogArea(Composite parent) { - Composite container = new Composite(parent, SWT.FILL); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - layout.marginWidth = layout.marginHeight = 5; - container.setLayout(layout); - GridData gd = new GridData(GridData.FILL_BOTH); - container.setLayoutData(gd); - - TabFolder tabFolder = new TabFolder(container, SWT.FILL); - tabFolder.setLayoutData(gd); - TabItem generalTabItem = new TabItem(tabFolder, SWT.NONE); - generalTabItem - .setText(EditorMessages.AttributeSection_Dialog_Tab_General); - Control control = createGeneralTabControl(generalTabItem.getParent()); - generalTabItem.setControl(control); - return container; - } - - /** - * @param parent - * @return - */ - private Control createGeneralTabControl(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 5; - composite.setLayout(layout); - GridData gd = new GridData(GridData.FILL_BOTH); - composite.setLayoutData(gd); - composite.setFont(parent.getFont()); - - attributeNameField = new StringDialogField(); -// attributeNameField.setRequired(true); - attributeNameField - .setLabelText(EditorMessages.AttributeSection_Dialog_AttributeName); - - attributeClassField = new ClassButtonDialogField(getProject()); -// attributeClassField.setRequired(true); - attributeClassField - .setLabelText(EditorMessages.AttributeSection_Dialog_AttributeClass);//$NON-NLS-1$ - - attributeClassField.setAutoOpenResource(false); - - defaultValueField = new StringDialogField(); - defaultValueField - .setLabelText(EditorMessages.AttributeSection_Dialog_DefaultValue); - - suggestedValueField = new StringDialogField(); - suggestedValueField - .setLabelText(EditorMessages.AttributeSection_Dialog_SuggestedValue); - - GridData data = new GridData(GridData.FILL_BOTH); - composite.setLayoutData(data); - - int numberOfColumns = 4; - GridLayout gl = new GridLayout(numberOfColumns, false); - composite.setLayout(gl); - - attributeNameField.doFillIntoGrid(null, composite, numberOfColumns); - - attributeClassField.doFillIntoGrid(null, composite, numberOfColumns); - - defaultValueField.doFillIntoGrid(null, composite, numberOfColumns); - - suggestedValueField.doFillIntoGrid(null, composite, numberOfColumns); - - LayoutUtil.setHorizontalGrabbing(attributeClassField.getTextControl( - null, composite)); - - // set the initial value for these fields. - attributeNameField.setText(attributeName); - attributeClassField.setText(attributeClass); - defaultValueField.setText(defaultValue); - suggestedValueField.setText(suggestedValue); - - return composite; - } - - /* - * @see org.eclipse.jface.window.Window#getInitialSize() - */ - protected Point getInitialSize() { - Point shellSize = super.getInitialSize(); - return new Point(Math.max( - convertHorizontalDLUsToPixels(MIN_DIALOG_WIDTH), shellSize.x), - shellSize.y); - } - - public IProject getProject() { - return project; - } - - /** - * - */ - protected void okPressed() { - attributeName = attributeNameField.getText(); - attributeClass = attributeClassField.getText(); - defaultValue = defaultValueField.getText(); - suggestedValue = suggestedValueField.getText(); - - super.okPressed(); - } - - public String getAttributeClass() { - return attributeClass; - } - - public void setAttributeClass(String attributeClass) { - this.attributeClass = attributeClass; - } - - public String getAttributeName() { - return attributeName; - } - - public void setAttributeName(String attributeName) { - this.attributeName = attributeName; - } - - public String getDefaultValue() { - return defaultValue; - } - - public void setDefaultValue(String defaultValue) { - this.defaultValue = defaultValue; - } - - public String getSuggestedValue() { - return suggestedValue; - } - - public void setSuggestedValue(String suggestedValue) { - this.suggestedValue = suggestedValue; - } - - public void setProject(IProject project) { - this.project = project; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/AddEditFacetDialog.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/AddEditFacetDialog.java deleted file mode 100644 index 5b5a1f025..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/AddEditFacetDialog.java +++ /dev/null @@ -1,208 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.dialog; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.LayoutUtil; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.StringDialogField; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.TabFolder; -import org.eclipse.swt.widgets.TabItem; - -/** - * The dialog is for adding and editing a facet. - * - * @author sfshi - * - */ -public class AddEditFacetDialog extends Dialog { - - private StringDialogField facetNameField; - - private StringDialogField displayNameField; - - private StringDialogField descriptionField; - - private boolean isNew; - - private static final int MIN_DIALOG_WIDTH = 300; - - private String facetName; - - private String displayName; - - private String description; - - /** - * Constructor of this dialog, could be used for adding and editing, usually - * it is used for adding; - * - * @param parentShell - * @param isNew - * whether this dialog is used for create a new facet or not; - */ - public AddEditFacetDialog(Shell parentShell, boolean isNew) { - super(parentShell); - this.isNew = isNew; - } - - /** - * Usually this contructor is used for editing a facet, passing the original - * values of facet here. - * - * @param parentShell - * @param facetName - * the original text value of facet-name element; - * @param displayName - * the original text value of display-name element; - * @param description - * the original text value of description element; - */ - public AddEditFacetDialog(Shell parentShell, String facetName, - String displayName, String description) { - super(parentShell); - this.facetName = facetName; - this.displayName = displayName; - this.description = description; - this.isNew = false; - } - - /* - * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) - */ - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - if (isNew) - newShell.setText(EditorMessages.FacetSection_Dialog_Title_Add); - else - newShell.setText(EditorMessages.FacetSection_Dialog_Title_Edit); - } - - /* - * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) - */ - protected Control createDialogArea(Composite parent) { - Composite container = new Composite(parent, SWT.FILL); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - layout.marginWidth = layout.marginHeight = 5; - container.setLayout(layout); - GridData gd = new GridData(GridData.FILL_BOTH); - container.setLayoutData(gd); - - TabFolder tabFolder = new TabFolder(container, SWT.FILL); - tabFolder.setLayoutData(gd); - TabItem generalTabItem = new TabItem(tabFolder, SWT.NONE); - generalTabItem.setText(EditorMessages.FacetSection_Dialog_Tab_General); - Control control = createGeneralTabControl(generalTabItem.getParent()); - generalTabItem.setControl(control); - return container; - } - - /** - * @param parent - * @return - */ - private Control createGeneralTabControl(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 5; - composite.setLayout(layout); - GridData gd = new GridData(GridData.FILL_BOTH); - composite.setLayoutData(gd); - composite.setFont(parent.getFont()); - - facetNameField = new StringDialogField(); -// facetNameField.setRequired(true); - facetNameField - .setLabelText(EditorMessages.FacetSection_Dialog_FacetName); - - displayNameField = new StringDialogField(); - displayNameField - .setLabelText(EditorMessages.FacetSection_Dialog_DisplayName); - - descriptionField = new StringDialogField(); - descriptionField - .setLabelText(EditorMessages.FacetSection_Dialog_Description); - - GridData data = new GridData(GridData.FILL_BOTH); - composite.setLayoutData(data); - - int numberOfColumns = 4; - GridLayout gl = new GridLayout(numberOfColumns, false); - composite.setLayout(gl); - - facetNameField.doFillIntoGrid(null, composite, numberOfColumns); - displayNameField.doFillIntoGrid(null, composite, numberOfColumns); - - descriptionField.doFillIntoGrid(null, composite, numberOfColumns); - - LayoutUtil.setHorizontalGrabbing(facetNameField.getTextControl(null, - composite)); - - // set the initial value for these fields. - facetNameField.setText(facetName); - displayNameField.setText(displayName); - descriptionField.setText(description); - - return composite; - } - - /* - * @see org.eclipse.jface.window.Window#getInitialSize() - */ - protected Point getInitialSize() { - Point shellSize = super.getInitialSize(); - return new Point(Math.max( - convertHorizontalDLUsToPixels(MIN_DIALOG_WIDTH), shellSize.x), - shellSize.y); - } - - protected void okPressed() { - facetName = facetNameField.getText(); - displayName = displayNameField.getText(); - description = descriptionField.getText(); - super.okPressed(); - } - - public String getDescription() { - return description; - } - - public String getDisplayName() { - return displayName; - } - - public String getFacetName() { - return facetName; - } - - public void setDescription(String description) { - this.description = description; - } - - public void setDisplayName(String displayName) { - this.displayName = displayName; - } - - public void setFacetName(String facetName) { - this.facetName = facetName; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/AddEditManagedPropertyDialog.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/AddEditManagedPropertyDialog.java deleted file mode 100644 index aa5aa2104..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/AddEditManagedPropertyDialog.java +++ /dev/null @@ -1,497 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.dialog; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.jdt.core.IType; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.window.Window; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.ClassButtonDialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.ComboDialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.IDialogFieldApplyListener; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.IStringButtonAdapter; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.LayoutUtil; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.StringButtonDialogField; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory; -import org.eclipse.jst.jsf.facesconfig.emf.ListEntriesType; -import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanType; -import org.eclipse.jst.jsf.facesconfig.emf.ManagedPropertyType; -import org.eclipse.jst.jsf.facesconfig.emf.MapEntriesType; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.IFacesConfigConstants; -import org.eclipse.jst.jsf.facesconfig.ui.section.AbstractFacesConfigSection; -import org.eclipse.jst.jsf.facesconfig.ui.util.JavaBeanProperty; -import org.eclipse.jst.jsf.facesconfig.ui.util.JavaBeanUtils; -import org.eclipse.jst.jsf.facesconfig.ui.util.JavaClassUtils; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; - -/** - * The dialog is for adding and editing managed property. - * - * @author sfshi - * - */ -public class AddEditManagedPropertyDialog extends Dialog { - - private static final int MIN_DIALOG_WIDTH = 300; - - private static final int DEFAULT_CONTROL_WIDTH = 200; - - private ComboDialogField nameField; - - private ClassButtonDialogField classField; - - private ComboDialogField valueTypeField; - - private StringButtonDialogField valueField; - - private IProject project; - - private String propertyName; - - private String propertyClass; - - private String valueType; - - /** - * the value could be a string, or instance of <code>NullValueType</code>, - * <code>MapEntriesType</code> and <code>ListEntriesType</code>. - */ - private Object valueObject; - - private ManagedBeanType managedBean; - - /** - * the list of this bean properties. - */ - private List beanPropertyList; - - /** - * the managed-property object that is editing, but it will be read-only. - */ - private ManagedPropertyType managedProperty; - - // private FormToolkit toolkit; - - private Composite parent; - - public static final String[] valueTypes = { IFacesConfigConstants.VALUE, - IFacesConfigConstants.NULL_VALUE, - IFacesConfigConstants.MAP_ENTRIES, - IFacesConfigConstants.LIST_ENTRIES }; - - private boolean isNew; - - private AbstractFacesConfigSection section; - - /** - * constructor for adding a managed property. - * - * @param parentShell - * @param managedBean - */ - public AddEditManagedPropertyDialog(Shell parentShell, - ManagedBeanType managedBean, AbstractFacesConfigSection section) { - super(parentShell); - this.isNew = true; - this.managedBean = managedBean; - this.section = section; - } - - /** - * - * @param parentShell - * @param managedProperty - */ - public AddEditManagedPropertyDialog(Shell parentShell, - ManagedPropertyType managedProperty, AbstractFacesConfigSection section) { - super(parentShell); - this.isNew = false; - this.managedProperty = managedProperty; - this.managedBean = (ManagedBeanType) managedProperty.eContainer(); - this.section = section; - } - - /* - * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) - */ - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - if (isNew) - newShell.setText(EditorMessages.AddEditManagedPropertyDialog_Add); - else - newShell.setText(EditorMessages.AddEditManagedPropertyDialog_Edit); - } - - /* - * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) - */ - protected Control createDialogArea(Composite parent_) { - Composite container = new Composite(parent_, SWT.FILL); - this.parent = container; - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - layout.marginWidth = layout.marginHeight = 5; - container.setLayout(layout); - GridData gd = new GridData(GridData.FILL_BOTH); - container.setLayoutData(gd); - - nameField = new ComboDialogField(SWT.DROP_DOWN | SWT.READ_ONLY - | SWT.BORDER); - nameField.setLabelText(EditorMessages.ManagedBeanPropertyEditDialog_PropertyName); - - int propertyCount = 0; - beanPropertyList = getBeanPropertyList(managedBean); - if (beanPropertyList != null) - propertyCount = beanPropertyList.size(); - - if (propertyCount > 0) { - String[] propertyNames = new String[propertyCount]; - - for (int i = 0; i < propertyCount; i++) { - JavaBeanProperty property = (JavaBeanProperty) beanPropertyList - .get(i); - propertyNames[i] = property.getName(); - } - nameField.setItems(propertyNames); - } - - nameField.setDialogFieldApplyListener(new IDialogFieldApplyListener() { - public void dialogFieldApplied(DialogField field) { - handleNameSelection(((ComboDialogField) field).getText()); - } - }); - - classField = new ClassButtonDialogField(null); - classField.setProject(getProject()); - classField.setLabelText(EditorMessages.ManagedBeanPropertyEditDialog_PropertyClass); - - valueTypeField = new ComboDialogField(SWT.DROP_DOWN | SWT.READ_ONLY - | SWT.BORDER); - valueTypeField.setLabelText(EditorMessages.ManagedBeanPropertyEditDialog_ValueType); - - valueTypeField.setItems(valueTypes); - valueTypeField - .setDialogFieldApplyListener(new IDialogFieldApplyListener() { - public void dialogFieldApplied(DialogField field) { - updateValueStatus(); - } - }); - - valueField = new StringButtonDialogField(new IStringButtonAdapter() { - public void changeControlPressed(DialogField field) { - handleChangeValue(valueTypeField.getText(), - ((StringButtonDialogField) field).getText()); - } - - }); - - valueField.setLabelText(EditorMessages.ManagedBeanPropertyEditDialog_Value);//$NON-NLS-1$ - valueField.setButtonLabel(EditorMessages.UI_Button_Edit_more); - - valueField.setDialogFieldApplyListener(new IDialogFieldApplyListener() { - - public void dialogFieldApplied(DialogField field) { - valueObject = ((StringButtonDialogField) field).getText(); - - } - }); - - GridData data = new GridData(GridData.FILL_BOTH); - container.setLayoutData(data); - - int numberOfColumns = 5; - GridLayout gl = new GridLayout(numberOfColumns, false); - container.setLayout(gl); - - nameField.doFillIntoGrid(null, container, numberOfColumns); - LayoutUtil.setWidthHint(nameField.getComboControl(null, container), - DEFAULT_CONTROL_WIDTH); - - classField.doFillIntoGrid(null, container, numberOfColumns - 1); - data = new GridData(SWT.FILL, SWT.CENTER, false, false); - data.horizontalSpan = 2; - classField.getChangeControl(null, container).setLayoutData(data); - LayoutUtil.setWidthHint(classField.getTextControl(null, container), - DEFAULT_CONTROL_WIDTH); - - valueTypeField.doFillIntoGrid(null, container, numberOfColumns); - - valueField.doFillIntoGrid(null, container, numberOfColumns); - - LayoutUtil.setHorizontalGrabbing(classField.getTextControl(null, - container)); - - valueTypeField.selectItem(0); - - if (!isNew && managedProperty != null) { - initFields(); - } - - return container; - } - - private void initFields() { - - if (managedProperty.getPropertyName() != null) - nameField.setText(managedProperty.getPropertyName() - .getTextContent()); - - if (managedProperty.getPropertyClass() != null) - classField.setText(managedProperty.getPropertyClass() - .getTextContent()); - - if (managedProperty.getValue() != null) { - valueTypeField.setText(valueTypes[0]); - valueField.setText(managedProperty.getValue().getTextContent()); - } else if (managedProperty.getNullValue() != null) - valueTypeField.setText(valueTypes[1]); - else if (managedProperty.getMapEntries() != null) - valueTypeField.setText(valueTypes[2]); - else if (managedProperty.getListEntries() != null) - valueTypeField.setText(valueTypes[3]); - else - valueTypeField.setText(valueTypes[0]); - updateValueStatus(); - } - - /** - * @param text - */ - protected void handleNameSelection(String text) { - int propertyCount = 0; - if (beanPropertyList != null) - propertyCount = beanPropertyList.size(); - - if (propertyCount > 0) { - for (int i = 0; i < propertyCount; i++) { - JavaBeanProperty property = (JavaBeanProperty) beanPropertyList - .get(i); - - if (property.getName().equals(text.trim())) { - classField.setText(property.getQualifiedType()); - break; - } - } - } - - } - - private void updateValueStatus() { - if (valueField == null) { - return; - } - valueObject = null; - if (valueTypeField.getText().equalsIgnoreCase( - IFacesConfigConstants.NULL_VALUE)) { - valueField.setEnabled(false); - valueObject = FacesConfigFactory.eINSTANCE.createNullValueType(); - } else if (valueTypeField.getText().equalsIgnoreCase( - IFacesConfigConstants.MAP_ENTRIES) - || valueTypeField.getText().equalsIgnoreCase( - IFacesConfigConstants.LIST_ENTRIES)) { - valueField.getTextControl(null, parent).setEditable(false); - valueField.setEnabled(true); - } else { - valueObject = ""; //$NON-NLS-1$ - valueField.getTextControl(null, parent).setEditable(true); - valueField.setEnabled(true); - } - } - - /** - * @param valueType_ - * @param value - */ - protected void handleChangeValue(String valueType_, String value) { - if (valueType_.equalsIgnoreCase(IFacesConfigConstants.VALUE)) { - handleChangeLongStringValue(value); - } else if (valueType_ - .equalsIgnoreCase(IFacesConfigConstants.MAP_ENTRIES)) { - handleChangeMapEntries(); - } else if (valueType_ - .equalsIgnoreCase(IFacesConfigConstants.LIST_ENTRIES)) { - handleChangeListEntries(); - } - } - - /** - * @param textControl - */ - private void handleChangeLongStringValue(String value) { - EditValueDialog valueDialog = new EditValueDialog(EditorPlugin - .getActiveShell(), value); - if (valueDialog.open() == Window.OK) { - valueField.setText((String) valueDialog.getResultData()); - valueObject = valueDialog.getResultData(); - } - } - - /** - * - */ - private void handleChangeMapEntries() { - - MapEntriesType mapEntries; - - if (valueObject instanceof MapEntriesType) - mapEntries = (MapEntriesType) valueObject; - else if (isNew || managedProperty.getMapEntries() == null) { - mapEntries = FacesConfigFactory.eINSTANCE.createMapEntriesType(); - } else { - mapEntries = (MapEntriesType) EcoreUtil.copy(managedProperty - .getMapEntries()); - } - - EditMapEntriesDialog dialog = new EditMapEntriesDialog(EditorPlugin - .getActiveShell(), mapEntries, section); - if (dialog.open() == Dialog.OK) { - valueObject = dialog.getMapEntries(); - } else { - //user cancel the dialog, then restore. - if (!isNew && managedProperty.getMapEntries() != null) - valueObject = EcoreUtil.copy(managedProperty - .getMapEntries()); - // else - // valueObject = null; - } - } - - private void handleChangeListEntries() { - ListEntriesType listEntries; - - if (valueObject instanceof ListEntriesType) - listEntries = (ListEntriesType) valueObject; - else if (isNew || managedProperty.getListEntries() == null) { - listEntries = FacesConfigFactory.eINSTANCE.createListEntriesType(); - } else { - listEntries = (ListEntriesType) EcoreUtil.copy(managedProperty - .getListEntries()); - } - - EditListEntriesDialog dialog = new EditListEntriesDialog(EditorPlugin - .getActiveShell(), listEntries, section); - if (dialog.open() == Dialog.OK) { - valueObject = dialog.getListEntries(); - } else { - //user cancel the dialog, then restore. - if (!isNew && managedProperty.getListEntries() != null) - valueObject = EcoreUtil.copy(managedProperty - .getListEntries()); - // else - // valueObject = null; - } - } - - /** - * Get a list of JavaBeanProperty that from the managed bean class. - * - * @return - */ - private List getBeanPropertyList(ManagedBeanType managedBean_) { - if (managedBean_.getManagedBeanClass() == null) - return null; - String beanClassName = managedBean_.getManagedBeanClass() - .getTextContent(); - IType classType = JavaClassUtils.getType(getProject(), beanClassName); - if (classType == null) { - return null; - } - List list = new ArrayList(); - JavaBeanProperty[] properties = JavaBeanUtils - .getBeanProperties(classType); - if (properties != null) { - for (int i = 0; i < properties.length; i++) { - list.add(properties[i]); - } - } - return list; - } - - /* - * @see org.eclipse.jface.window.Window#getInitialSize() - */ - protected Point getInitialSize() { - Point shellSize = super.getInitialSize(); - return new Point(Math.max( - convertHorizontalDLUsToPixels(MIN_DIALOG_WIDTH), shellSize.x), - shellSize.y); - } - - public IProject getProject() { - if (project == null) { - project = (IProject) section.getPage().getEditor().getAdapter( - IProject.class); - } - return project; - } - - /** - * - */ - protected void okPressed() { - propertyName = nameField.getText(); - propertyClass = classField.getText(); - valueType = valueTypeField.getText(); - - super.okPressed(); - } - - public String getPropertyClass() { - return propertyClass; - } - - public void setAttributeClass(String attributeClass) { - this.propertyClass = attributeClass; - } - - public String getPropertyName() { - return propertyName; - } - - public void setAttributeName(String attributeName) { - this.propertyName = attributeName; - } - - public String getValueType() { - return valueType; - } - - public void setValueType(String defaultValue) { - this.valueType = defaultValue; - } - - public void setProject(IProject project) { - this.project = project; - } - - public Object getValueObject() { - return valueObject; - } - - public void setValueObject(Object valueObject) { - this.valueObject = valueObject; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/AddEditMapEntryDialog.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/AddEditMapEntryDialog.java deleted file mode 100644 index 7586e7333..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/AddEditMapEntryDialog.java +++ /dev/null @@ -1,230 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.dialog; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.LayoutUtil; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.StringDialogField; -import org.eclipse.jst.jsf.common.ui.internal.guiutils.SWTUtils; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.jst.jsf.facesconfig.ui.IFacesConfigConstants; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; - -/** - * The dialog is for adding and editing map-entry. - * - * @author sfshi - * - */ -public class AddEditMapEntryDialog extends Dialog { - - private static final int MIN_DIALOG_WIDTH = 300; - - private static final int VALUE_DEFAULT_LINENUMS = 10; - - private boolean isNew; - - private StringDialogField keyField; - - private Button nullValueTypeButton; - - private StringDialogField valueField; - - private String key; - - private String value; - - private boolean isNullValue; - - public AddEditMapEntryDialog(Shell parentShell, boolean isNew) { - super(parentShell); - this.isNew = isNew; - } - - /** - * - * @param parentShell - * @param attributeName - * @param attributeClass - * @param defaultValue - * @param suggestedValue - */ - public AddEditMapEntryDialog(Shell parentShell, String attributeName, - String attributeClass, String defaultValue, String suggestedValue) { - super(parentShell); - this.isNew = false; - } - - /* - * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) - */ - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - if (isNew) - // TODO change it to "add" - newShell.setText(EditorMessages.MapEntryEditPage_Title); - else - newShell.setText(EditorMessages.MapEntryEditPage_Title); - } - - /* - * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) - */ - protected Control createDialogArea(Composite parent) { - Composite container = new Composite(parent, SWT.FILL); - GridData gd = new GridData(GridData.FILL_BOTH); - container.setLayoutData(gd); - - GridLayout gl = new GridLayout(); - gl.verticalSpacing = 0; - gl.numColumns = 1; - container.setLayout(gl); - - layoutKeySection(container); - layoutValueSection(container); - if (!isNew) { - initFields(); - } - return container; - } - - private void initFields() { - keyField.setText(key); - if (this.isNullValue) { - nullValueTypeButton.setSelection(true); - valueField.setText(""); - valueField.setEnabled(false); - } else { - nullValueTypeButton.setSelection(false); - valueField.setEnabled(true); - valueField.setText(value); - } - } - - public void layoutKeySection(Composite parent) { - keyField = new StringDialogField(); - keyField.setLabelText(EditorMessages.MapEntryEditGroup_Key); //$NON-NLS-1$ - Composite - - keySection = SWTUtils.createComposite(parent, SWT.NONE); - - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - keySection.setLayoutData(gd); - - int numberOfColumns = 3; - GridLayout gl = new GridLayout(numberOfColumns, false); - keySection.setLayout(gl); - - keyField.doFillIntoGrid(null, keySection, numberOfColumns); - - LayoutUtil.setGrabHorizontal(keyField.getTextControl(null, keySection), - true); - - } - - public void layoutValueSection(Composite parent) { - Composite - - valueSection = SWTUtils.createComposite(parent, SWT.NONE); - - GridData gd = new GridData(GridData.FILL_BOTH); - valueSection.setLayoutData(gd); - - int numberOfColumns = 3; - GridLayout gl = new GridLayout(numberOfColumns, false); - gl.verticalSpacing = 10; - gl.marginHeight = 10; - valueSection.setLayout(gl); - - nullValueTypeButton = SWTUtils.createCheckBox(valueSection, - IFacesConfigConstants.NULL_VALUE, 2); - - nullValueTypeButton.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent e) { - valueField.setEnabled(!nullValueTypeButton.getSelection()); - - } - - }); - valueField = new StringDialogField(VALUE_DEFAULT_LINENUMS); - - valueField.setLabelText(EditorMessages.ValueEditGroup_Value); //$NON-NLS-1$ - valueField.doFillIntoGrid(null, valueSection, numberOfColumns); - - gd = (GridData) valueField.getLabelControl(null, valueSection) - .getLayoutData(); - gd.verticalAlignment = gd.verticalAlignment | GridData.GRAB_VERTICAL; - LayoutUtil.setHorizontalGrabbing(valueField.getTextControl(null, - valueSection)); - - gd = (GridData) valueField.getTextControl(null, valueSection) - .getLayoutData(); - gd.verticalAlignment = gd.verticalAlignment | GridData.FILL_VERTICAL; - - } - - /* - * @see org.eclipse.jface.window.Window#getInitialSize() - */ - protected Point getInitialSize() { - Point shellSize = super.getInitialSize(); - return new Point(Math.max( - convertHorizontalDLUsToPixels(MIN_DIALOG_WIDTH), shellSize.x), - shellSize.y); - } - - /** - * - */ - protected void okPressed() { - - key = this.keyField.getText().trim(); - value = this.valueField.getText().trim(); - isNullValue = nullValueTypeButton.getSelection(); - super.okPressed(); - } - - public boolean isNullValue() { - return isNullValue; - } - - public void setNullValue(boolean isNullValue) { - this.isNullValue = isNullValue; - } - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/AddEditPropertyDialog.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/AddEditPropertyDialog.java deleted file mode 100644 index 5d80eecc2..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/AddEditPropertyDialog.java +++ /dev/null @@ -1,243 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.dialog; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.ClassButtonDialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.LayoutUtil; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.StringDialogField; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.TabFolder; -import org.eclipse.swt.widgets.TabItem; - -/** - * The dialog is for adding and editing property. - * - * @author sfshi - * - */ -public class AddEditPropertyDialog extends Dialog { - - private static final int MIN_DIALOG_WIDTH = 300; - - private StringDialogField propertyNameField; - - private ClassButtonDialogField propertyClassField; - - private StringDialogField defaultValueField; - - private StringDialogField suggestedValueField; - - private IProject project; - - private boolean isNew; - - private String propertyName; - - private String propertyClass; - - private String defaultValue; - - private String suggestedValue; - - /** - * - * @param parentShell - * @param isNew - */ - public AddEditPropertyDialog(Shell parentShell, boolean isNew) { - super(parentShell); - this.isNew = isNew; - } - - /** - * - * @param parentShell - * @param propertyName - * @param propertyClass - * @param defaultValue - * @param suggestedValue - */ - public AddEditPropertyDialog(Shell parentShell, String propertyName, - String propertyClass, String defaultValue, String suggestedValue) { - super(parentShell); - this.propertyName = propertyName; - this.propertyClass = propertyClass; - this.defaultValue = defaultValue; - this.suggestedValue = suggestedValue; - this.isNew = false; - } - - /* - * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) - */ - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - if (isNew) - newShell - .setText(EditorMessages.PropertySection_Dialog_Title_Add); - else - - newShell - .setText(EditorMessages.PropertySection_Dialog_Title_Edit); - } - - /* - * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) - */ - protected Control createDialogArea(Composite parent) { - Composite container = new Composite(parent, SWT.FILL); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - layout.marginWidth = layout.marginHeight = 5; - container.setLayout(layout); - GridData gd = new GridData(GridData.FILL_BOTH); - container.setLayoutData(gd); - - TabFolder tabFolder = new TabFolder(container, SWT.FILL); - tabFolder.setLayoutData(gd); - TabItem generalTabItem = new TabItem(tabFolder, SWT.NONE); - generalTabItem - .setText(EditorMessages.PropertySection_Dialog_Tab_General); - Control control = createGeneralTabControl(generalTabItem.getParent()); - generalTabItem.setControl(control); - return container; - } - - /** - * @param parent - * @return - */ - private Control createGeneralTabControl(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 5; - composite.setLayout(layout); - GridData gd = new GridData(GridData.FILL_BOTH); - composite.setLayoutData(gd); - composite.setFont(parent.getFont()); - - propertyNameField = new StringDialogField(); - // propertyNameField.setRequired(true); - propertyNameField - .setLabelText(EditorMessages.PropertySection_Dialog_PropertyName); - - propertyClassField = new ClassButtonDialogField(getProject()); - // propertyClassField.setRequired(true); - propertyClassField - .setLabelText(EditorMessages.PropertySection_Dialog_PropertyClass);//$NON-NLS-1$ - - propertyClassField.setAutoOpenResource(false); - - defaultValueField = new StringDialogField(); - defaultValueField - .setLabelText(EditorMessages.PropertySection_Dialog_DefaultValue); - - suggestedValueField = new StringDialogField(); - suggestedValueField - .setLabelText(EditorMessages.PropertySection_Dialog_SuggestedValue); - - GridData data = new GridData(GridData.FILL_BOTH); - composite.setLayoutData(data); - - int numberOfColumns = 4; - GridLayout gl = new GridLayout(numberOfColumns, false); - composite.setLayout(gl); - - propertyNameField.doFillIntoGrid(null, composite, numberOfColumns); - - propertyClassField.doFillIntoGrid(null, composite, numberOfColumns); - - defaultValueField.doFillIntoGrid(null, composite, numberOfColumns); - - suggestedValueField.doFillIntoGrid(null, composite, numberOfColumns); - - LayoutUtil.setHorizontalGrabbing(propertyClassField.getTextControl( - null, composite)); - - // set the initial value for these fields. - propertyNameField.setText(propertyName); - propertyClassField.setText(propertyClass); - defaultValueField.setText(defaultValue); - suggestedValueField.setText(suggestedValue); - - return composite; - } - - /* - * @see org.eclipse.jface.window.Window#getInitialSize() - */ - protected Point getInitialSize() { - Point shellSize = super.getInitialSize(); - return new Point(Math.max( - convertHorizontalDLUsToPixels(MIN_DIALOG_WIDTH), shellSize.x), - shellSize.y); - } - - protected IProject getProject() { - return project; - } - - protected void okPressed() { - propertyName = propertyNameField.getText(); - propertyClass = propertyClassField.getText(); - defaultValue = defaultValueField.getText(); - suggestedValue = suggestedValueField.getText(); - - super.okPressed(); - } - - public String getDefaultValue() { - return defaultValue; - } - - public void setDefaultValue(String defaultValue) { - this.defaultValue = defaultValue; - } - - public String getPropertyClass() { - return propertyClass; - } - - public void setPropertyClass(String propertyClass) { - this.propertyClass = propertyClass; - } - - public String getPropertyName() { - return propertyName; - } - - public void setPropertyName(String propertyName) { - this.propertyName = propertyName; - } - - public String getSuggestedValue() { - return suggestedValue; - } - - public void setSuggestedValue(String suggestedValue) { - this.suggestedValue = suggestedValue; - } - - public void setProject(IProject project) { - this.project = project; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/AddEditRendererDialog.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/AddEditRendererDialog.java deleted file mode 100644 index 1c0d3b613..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/AddEditRendererDialog.java +++ /dev/null @@ -1,270 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.dialog; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.ClassButtonDialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.IStringButtonAdapter; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.LayoutUtil; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.StringButtonDialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.StringDialogField; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.IFacesConfigConstants; -import org.eclipse.jst.jsf.facesconfig.ui.page.IFacesConfigPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.TabFolder; -import org.eclipse.swt.widgets.TabItem; - -/** - * @author Bryan Yang - * - */ -public class AddEditRendererDialog extends Dialog { - - private static final int MIN_DIALOG_WIDTH = 300; - - private StringDialogField rendererNameField; - - private ClassButtonDialogField rendererClassField; - - private StringButtonDialogField componentFamilyField; - - private StringDialogField renderTypeField; - - private IProject project; - - private String rendererName; - - private String rendererClass; - - private String componentFamily; - - private String rendererType; - - private boolean isNew; - - private IFacesConfigPage page; - - /** - * @param parentShell - * @param page - * @param isNew - */ - public AddEditRendererDialog(Shell parentShell, IFacesConfigPage page, - boolean isNew) { - super(parentShell); - this.page = page; - this.isNew = isNew; - } - - /** - * - * @param parentShell - * @param rendererName - * @param rendererClass - * @param componentFamily - * @param renderType - */ - public AddEditRendererDialog(Shell parentShell, String rendererName, - String rendererClass, String componentFamily, String renderType) { - super(parentShell); - this.rendererName = rendererName; - this.rendererClass = rendererClass; - this.componentFamily = componentFamily; - this.rendererType = renderType; - this.isNew = false; - } - - /* - * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) - */ - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - if (isNew) - newShell.setText(EditorMessages.RendererSection_Dialog_Title_Add); - else - newShell.setText(EditorMessages.RendererSection_Dialog_Title_Edit); - } - - /* - * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) - */ - protected Control createDialogArea(Composite parent) { - Composite container = new Composite(parent, SWT.FILL); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - layout.marginWidth = layout.marginHeight = 5; - container.setLayout(layout); - GridData gd = new GridData(GridData.FILL_BOTH); - container.setLayoutData(gd); - - TabFolder tabFolder = new TabFolder(container, SWT.FILL); - tabFolder.setLayoutData(gd); - TabItem generalTabItem = new TabItem(tabFolder, SWT.NONE); - generalTabItem - .setText(EditorMessages.RendererSection_Dialog_Tab_General); - Control control = createGeneralTabControl(generalTabItem.getParent()); - generalTabItem.setControl(control); - return container; - } - - /** - * @param parent - * @return - */ - private Control createGeneralTabControl(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 5; - composite.setLayout(layout); - GridData gd = new GridData(GridData.FILL_BOTH); - composite.setLayoutData(gd); - composite.setFont(parent.getFont()); - - rendererNameField = new StringDialogField(); - rendererNameField - .setLabelText(EditorMessages.RendererSection_Dialog_DisplayName); - - rendererClassField = new ClassButtonDialogField(getProject()); -// rendererClassField.setRequired(true); - rendererClassField - .setLabelText(EditorMessages.RendererSection_Dialog_RendererClass);//$NON-NLS-1$ - rendererClassField.setProject(getProject()); - rendererClassField.setSuperClassName(IFacesConfigConstants.RENDERER_SUPER_CLASS); - rendererClassField.setAutoOpenResource(false); - - componentFamilyField = new StringButtonDialogField( - new IStringButtonAdapter() { - public void changeControlPressed(DialogField field) { - Shell shell = EditorPlugin.getActiveShell(); - ComponentListDialog dialog = new ComponentListDialog( - shell, - page, - page.getInput(), - EditorMessages.RendererSection_Dialog_ComponentFamilyCaption, - EditorMessages.RendererSection_Dialog_ComponentFamilyLabel); - if (dialog.open() == Dialog.OK) { - componentFamilyField.setText(dialog.getValue()); - } - } - }); - componentFamilyField - .setLabelText(EditorMessages.RendererSection_Dialog_ComponentFamilyValue); -// componentFamilyField.setRequired(true); - - renderTypeField = new StringDialogField(); -// renderTypeField.setRequired(true); - renderTypeField - .setLabelText(EditorMessages.RendererSection_Dialog_TypeValue); - - GridData data = new GridData(GridData.FILL_BOTH); - composite.setLayoutData(data); - - int numberOfColumns = 4; - GridLayout gl = new GridLayout(numberOfColumns, false); - composite.setLayout(gl); - - rendererNameField.doFillIntoGrid(null, composite, numberOfColumns); - - componentFamilyField.doFillIntoGrid(null, composite, numberOfColumns); - - renderTypeField.doFillIntoGrid(null, composite, numberOfColumns); - - rendererClassField.doFillIntoGrid(null, composite, numberOfColumns); - - LayoutUtil.setHorizontalGrabbing(rendererClassField.getTextControl( - null, composite)); - - // set the initial value for these fields. - rendererNameField.setText(rendererName); - rendererClassField.setText(rendererClass); - componentFamilyField.setText(componentFamily); - renderTypeField.setText(rendererType); - - return composite; - } - - /* - * @see org.eclipse.jface.window.Window#getInitialSize() - */ - protected Point getInitialSize() { - Point shellSize = super.getInitialSize(); - return new Point(Math.max( - convertHorizontalDLUsToPixels(MIN_DIALOG_WIDTH), shellSize.x), - shellSize.y); - } - - /** - * @return the associated project - */ - public IProject getProject() { - return project; - } - - /** - * - */ - protected void okPressed() { - rendererName = rendererNameField.getText(); - rendererClass = rendererClassField.getText(); - componentFamily = componentFamilyField.getText(); - rendererType = renderTypeField.getText(); - - super.okPressed(); - } - - public String getRendererClass() { - return rendererClass; - } - - public void setRendererClass(String rendererClass) { - this.rendererClass = rendererClass; - } - - public String getRendererName() { - return rendererName; - } - - public void setRendererName(String rendererName) { - this.rendererName = rendererName; - } - - public String getComponentFamily() { - return componentFamily; - } - - public void setComponentFamily(String componentFamily) { - this.componentFamily = componentFamily; - } - - public String getRendererType() { - return rendererType; - } - - public void setRendererType(String rendererType) { - this.rendererType = rendererType; - } - - public void setProject(IProject project) { - this.project = project; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/CommonListDialog.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/CommonListDialog.java deleted file mode 100644 index 75dd0bc20..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/CommonListDialog.java +++ /dev/null @@ -1,230 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.dialog; - -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.emf.edit.domain.EditingDomain; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jst.jsf.common.ui.internal.guiutils.SWTUtils; -import org.eclipse.jst.jsf.facesconfig.ui.page.IFacesConfigPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; - -/** - * @author Bryan Yang - * - */ -public class CommonListDialog extends Dialog implements - ISelectionChangedListener, ISelectionProvider { - private static final int MIN_DIALOG_WIDTH = 300; - - private Text inputText; - - private StructuredViewer structuredViewer; - - private String value; - - private IFacesConfigPage page; - - private Object input; - - private String label; - - private String caption; - - /** The mini width for the text control */ - private static final int TEXT_MINI_WIDTH = 100; - - protected CommonListDialog(Shell parentShell, IFacesConfigPage page, - Object input, String caption, String label) { - super(parentShell); - this.page = page; - this.input = input; - this.label = label; - this.caption = caption; - parentShell.setText(caption); - } - - /* - * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) - */ - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - newShell.setText(caption); - } - - - /* - * @see org.eclipse.jface.window.Window#getInitialSize() - */ - protected Point getInitialSize() { - Point shellSize = super.getInitialSize(); - return new Point(Math.max( - convertHorizontalDLUsToPixels(MIN_DIALOG_WIDTH), shellSize.x), - shellSize.y); - } - - /* - * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) - */ - protected Control createDialogArea(Composite parent) { - Composite composite = SWTUtils.createComposite(parent, 1); - - SWTUtils.createLabel(composite, label, 1); //$NON-NLS-1$ - - inputText = SWTUtils.createTextBox(composite, 1); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - gd.widthHint = TEXT_MINI_WIDTH; - inputText.setLayoutData(gd); - - structuredViewer = createViewer(composite); - structuredViewer.addSelectionChangedListener(this); - - return composite; - } - - /** - * Create the structured viewer, set up content & label provider for it. - * Defaultly create a tableviewer. - * - * @param parent - * @return the structured viewer - */ - protected StructuredViewer createViewer(Composite parent) { - - GridData gd = new GridData(GridData.FILL_BOTH); - gd.heightHint = 200; - gd.widthHint = 150; - parent.setLayoutData(gd); - GridLayout layout = new GridLayout(); - parent.setLayout(layout); - - TableViewer tableViewer = new TableViewer(parent, SWT.SINGLE - | SWT.H_SCROLL | SWT.V_SCROLL); - gd = new GridData(GridData.FILL_BOTH); - tableViewer.getControl().setLayoutData(gd); - - tableViewer.setContentProvider(new AdapterFactoryContentProvider( - getAdapterFactory())); - tableViewer.setLabelProvider(new AdapterFactoryLabelProvider( - getAdapterFactory())); - configViewer(tableViewer); - tableViewer.setInput(input); - - return tableViewer; - } - - /** - * set the structuredViewer's input - * - * @param input - */ - private void setViewerInput(Object input) { - structuredViewer.setInput(input); - this.input = input; - } - - /** - * get the input object of this section. - */ - public Object getInput() { - return input; - } - - /** - * set input object for this section. - */ - public void setInput(Object newInput) { - input = newInput; - setViewerInput(input); - } - - /** - * Config the viewer, such as set a filter and so on. Sub classes should - * override this method to add filter. - * - * @param structuredViewer_ - */ - protected void configViewer(StructuredViewer structuredViewer_) { - // do nothing; sub-classes should override - } - - //TODO: why bother with this interface? - public void selectionChanged(SelectionChangedEvent event) { - // selectionChanged not handled - - } - - public void addSelectionChangedListener(ISelectionChangedListener listener) { - // do nothing; not handling setSelection - } - - public ISelection getSelection() { - return structuredViewer.getSelection(); - } - - public void removeSelectionChangedListener( - ISelectionChangedListener listener) { - // do nothing; not handling setSelection - } - - public void setSelection(ISelection selection) { - // do nothing; not handling change in selection - } - - /** - * the convenient method to get the AdapterFactory instance of the editor; - * - * @return the AdapterFactory instance. - */ - public AdapterFactory getAdapterFactory() { - return (AdapterFactory) page.getEditor().getAdapter( - AdapterFactory.class); - } - - /** - * the convenient method to get the EditingDomain instance of the editor; - * - * @return the EditingDomain instance. - */ - public EditingDomain getEditingDomain() { - return (EditingDomain) page.getEditor().getAdapter(EditingDomain.class); - } - - public String getValue() { - return value; - } - public void setValue(String value) { - this.value = value; - refresh(); - } - - private void refresh() - { - inputText.setText(value) ; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/ComponentListDialog.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/ComponentListDialog.java deleted file mode 100644 index 19f1f4dbc..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/ComponentListDialog.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.dialog; - -import java.util.Iterator; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jst.jsf.facesconfig.emf.ComponentType; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.ui.page.IFacesConfigPage; -import org.eclipse.swt.widgets.Shell; - -/** - * @author Bryan Yang - * - */ -public class ComponentListDialog extends CommonListDialog { - - public void selectionChanged(SelectionChangedEvent event) { - IStructuredSelection ssel = StructuredSelection.EMPTY; - ISelection selection = getSelection(); - if (selection instanceof IStructuredSelection) { - ssel = (IStructuredSelection) selection; - } - - if (!ssel.isEmpty()) { - for (Iterator iter = ssel.iterator(); iter.hasNext();) { - ComponentType element = (ComponentType) iter.next(); - if (element.getComponentType() != null) - setValue(element.getComponentType().getTextContent()); - else - setValue(""); - } - - } - } - - protected ComponentListDialog(Shell parentShell, IFacesConfigPage page, - Object input, String caption, String label) { - super(parentShell, page, input, caption, label); - } - - protected void configViewer(StructuredViewer structuredViewer) { - super.configViewer(structuredViewer); - structuredViewer.addFilter(new ViewerFilter() { - public boolean select(Viewer viewer, Object parentElement, - Object element) { - return FacesConfigPackage.eINSTANCE.getComponentType() - .isInstance(element); - } - }); - - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/DialogUtil.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/DialogUtil.java deleted file mode 100644 index d8c561826..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/DialogUtil.java +++ /dev/null @@ -1,123 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.dialog; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.emf.common.util.EList; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jface.window.Window; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.JavaUIHelper; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigType; -import org.eclipse.jst.jsf.facesconfig.emf.RenderKitIdType; -import org.eclipse.jst.jsf.facesconfig.emf.RenderKitType; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.dialogs.SelectionDialog; - -/** - * @author Zhi-peng Zhang - * @version - */ -public class DialogUtil { - - public static String openClassDialog(Shell shell, IProject project, - String superType, int tyle) { - SelectionDialog dialog = JavaUIHelper - .openSelectionDialog(shell, project, superType, tyle); - - // dialog could be null - if (dialog != null) - { - dialog.setTitle(EditorMessages.FindType); - dialog.setMessage(EditorMessages.FindType_Filter); - if (dialog.open() == SelectionDialog.OK) { - Object[] result = dialog.getResult(); - IType searchedType = (IType) result[0]; - return searchedType.getFullyQualifiedName(); - } - } - return null; - } - - public static String openRenderKitDialog(Shell shell, - FacesConfigType facesConfig) { - if (facesConfig != null) { - EList list = facesConfig.getRenderKit(); - ArrayList ids = new ArrayList(); - for (int i = 0, n = list.size(); i < n; i++) { - RenderKitIdType renderKitId = ((RenderKitType) list.get(i)) - .getRenderKitId(); - if (renderKitId != null) { - if (!"".equals(renderKitId.getTextContent())) { - ids.add(renderKitId.getTextContent()); - } - } - } - String[] idArray = (String[]) ids.toArray(new String[ids.size()]); - Arrays.sort(idArray); - ListChoiceDialog dialog = new ListChoiceDialog( - shell, - idArray, - EditorMessages.DefaultRenderKitIDSection_Wizard_Page_LabelText); - if (dialog.open() == SelectionDialog.OK) { - String result = dialog.getResult(); - if (!"".equals(result)) { - return result; - } - } - } - return null; - } - - public static String openLocaleDialog(Shell shell, List existedLocaleList) { - LocaleDialog dialog = new LocaleDialog(shell, existedLocaleList); - if (dialog.open() == Window.OK) { - String result = dialog.getResult(); - if (!"".equals(result)) { - return result; - } - } - return null; - } - - public static String openMessageBundleDialog(Shell shell, IProject project, - List existedBundleList) { - IJavaProject javaProject = null; - - try { - if (project != null && project.hasNature(JavaCore.NATURE_ID)) { - javaProject = JavaCore.create(project); - } else { - return null; - } - } catch (CoreException e) { - // Ignore - } - MessageBundleSelectionDialog dialog = new MessageBundleSelectionDialog( - shell, javaProject, existedBundleList); - - if (dialog.open() == SelectionDialog.OK) { - String newValue = (String) dialog.getResult()[0]; - if (!"".equalsIgnoreCase(newValue)) { - return newValue; - } - } - return null; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/EditListEntriesDialog.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/EditListEntriesDialog.java deleted file mode 100644 index b89a83b16..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/EditListEntriesDialog.java +++ /dev/null @@ -1,399 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.jst.jsf.facesconfig.ui.dialog; - -import org.eclipse.core.resources.IProject; -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.ClassButtonDialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogFieldBase; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.LayoutUtil; -import org.eclipse.jst.jsf.common.ui.internal.guiutils.SWTUtils; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.emf.ListEntriesType; -import org.eclipse.jst.jsf.facesconfig.emf.NullValueType; -import org.eclipse.jst.jsf.facesconfig.emf.ValueClassType; -import org.eclipse.jst.jsf.facesconfig.emf.ValueType; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.section.AbstractFacesConfigSection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.MouseAdapter; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; - -/** - * - * @author sfshi - * - */ -public class EditListEntriesDialog extends Dialog { - - private static final int MIN_DIALOG_WIDTH = 300; - - private static final int TABLE_DEFAULT_HEIGHT = 160; - - private ClassButtonDialogField valueClassField; - - private IProject project; - - private TableViewer tableViewer; - - private Button removeButton; - - private Button editButton; - - private ListEntriesType listEntries; - - private AbstractFacesConfigSection section; - - /** - * - * @param parentShell - * @param listEntries - * the list-entries element that working on. - * @param section - */ - public EditListEntriesDialog(Shell parentShell, - ListEntriesType listEntries, AbstractFacesConfigSection section) { - super(parentShell); - this.listEntries = listEntries; - this.section = section; - } - - /* - * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) - */ - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - newShell.setText("Editing list-entries"); - } - - /* - * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) - */ - protected Control createDialogArea(Composite parent) { - Composite container = new Composite(parent, SWT.FILL); - GridData data = new GridData(GridData.FILL_BOTH); - container.setLayoutData(data); - - GridLayout gl = new GridLayout(); - gl.verticalSpacing = 0; - // gl.marginHeight = 0; - container.setLayout(gl); - createKeyValueSection(container); - createTableSection(container); - - initFields(); - return container; - } - - private void initFields() { - - if (listEntries.getValueClass() != null) - valueClassField.setText(listEntries.getValueClass() - .getTextContent()); - - tableViewer.setInput(listEntries); - } - - private void createKeyValueSection(Composite parent) { - valueClassField = new ClassButtonDialogField(getProject()); - - valueClassField - .setLabelText(EditorMessages.InitializationSection_MapType_ValueClass);//$NON-NLS-1$ - Composite typeSelectionSection = SWTUtils.createComposite(parent, - SWT.NONE); - - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - typeSelectionSection.setLayoutData(gd); - - int numberOfColumns = 4; - GridLayout gl = new GridLayout(numberOfColumns, false); - typeSelectionSection.setLayout(gl); - - valueClassField.doFillIntoGrid(null, typeSelectionSection, - numberOfColumns); - LayoutUtil.setHorizontalGrabbing(valueClassField.getTextControl(null, - parent)); - } - - /** - * - * @param parent - */ - private void createTableSection(Composite parent) { - Composite mapValueSection = SWTUtils.createComposite(parent, SWT.NONE); - - GridData gd = new GridData(GridData.FILL_BOTH); - mapValueSection.setLayoutData(gd); - - int numberOfColumns = 3; - GridLayout gl = new GridLayout(numberOfColumns, false); - mapValueSection.setLayout(gl); - - DialogField valuesTitle = new DialogFieldBase(); - valuesTitle - .setLabelText(EditorMessages.InitializationSection_MapTable_Title);//$NON-NLS-1$ - - valuesTitle.doFillIntoGrid(null, mapValueSection, numberOfColumns); - - Table mapTable = new Table(mapValueSection, SWT.FULL_SELECTION - | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); - - mapTable.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent e) { - updateButtonsStatus(); - - } - - }); - mapTable.addMouseListener(new MouseAdapter() { - public void mouseDoubleClick(MouseEvent e) { - if (((IStructuredSelection) tableViewer.getSelection()).size() > 0) - editButtonSelected(null); - } - }); - gd = new GridData(GridData.FILL_BOTH); - gd.horizontalSpan = 1; - gd.heightHint = TABLE_DEFAULT_HEIGHT; - mapTable.setLayoutData(gd); - mapTable.setHeaderVisible(true); - mapTable.setLinesVisible(true); - TableLayout layout = new TableLayout(); - layout.addColumnData(new ColumnWeightData(1, true)); - mapTable.setLayout(layout); - - TableColumn keyCol = new TableColumn(mapTable, SWT.NONE); - keyCol - .setText(EditorMessages.InitializationSection_MapTable_Value);//$NON-NLS-1$ - layout.addColumnData(new ColumnWeightData(1, true)); - keyCol.setResizable(true); - - tableViewer = new TableViewer(mapTable); - tableViewer.setContentProvider(new AdapterFactoryContentProvider( - getAdapterFactory())); - tableViewer.setLabelProvider(new AdapterFactoryLabelProvider( - getAdapterFactory())); - - tableViewer.addFilter(new ViewerFilter() { - public boolean select(Viewer viewer, Object parentElement, - Object element) { - return FacesConfigPackage.eINSTANCE.getValueType().isInstance( - element) - || FacesConfigPackage.eINSTANCE.getNullValueType() - .isInstance(element); - } - }); - - Composite operationContainer = null; - - operationContainer = SWTUtils - .createComposite(mapValueSection, SWT.NONE); - - gd = new GridData(GridData.FILL_VERTICAL); - operationContainer.setLayoutData(gd); - gl = new GridLayout(); - operationContainer.setLayout(gl); - - Button addButton = SWTUtils.createPushButton(operationContainer, - EditorMessages.UI_Button_Add_more); //$NON-NLS-1$ - - gd = new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING); - gd.grabExcessHorizontalSpace = false; - addButton.setLayoutData(gd); - addButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - addButtonSelected(e); - } - }); - - editButton = SWTUtils.createPushButton(operationContainer, - EditorMessages.UI_Button_Edit_more); - - gd = new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING); - gd.grabExcessHorizontalSpace = false; - editButton.setLayoutData(gd); - editButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - editButtonSelected(e); - } - - }); - removeButton = SWTUtils.createPushButton(operationContainer, - EditorMessages.UI_Button_Remove); //$NON-NLS-1$ - - gd = new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING); - gd.grabExcessHorizontalSpace = false; - removeButton.setLayoutData(gd); - removeButton.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent e) { - removeButtonSelected(); - } - - }); - editButton.setEnabled(false); - removeButton.setEnabled(false); - } - - private AdapterFactory getAdapterFactory() { - return section.getAdapterFactory(); - } - - private void addButtonSelected(SelectionEvent e) { - - EditValueDialog dialog = new EditValueDialog(EditorPlugin - .getActiveShell(), true, false, null); - if (dialog.open() == Dialog.OK) { - if (dialog.isNullValue()) { - NullValueType nullValue = FacesConfigFactory.eINSTANCE - .createNullValueType(); - listEntries.getNullValue().add(nullValue); - } else { - ValueType value = FacesConfigFactory.eINSTANCE - .createValueType(); - value.setTextContent((String) dialog.getResultData()); - listEntries.getValue().add(value); - } - } - - } - - private void editButtonSelected(SelectionEvent e) { - Object select = ((IStructuredSelection) tableViewer.getSelection()) - .getFirstElement(); - boolean isNullValue; - String valueText = null; - if (select instanceof NullValueType) - isNullValue = true; - else { - isNullValue = false; - valueText = ((ValueType) select).getTextContent(); - } - - EditValueDialog dialog = new EditValueDialog(EditorPlugin - .getActiveShell(), true, isNullValue, valueText); - if (dialog.open() == Dialog.OK) { - if (isNullValue && !dialog.isNullValue()) { - listEntries.getNullValue().remove(select); - ValueType value = FacesConfigFactory.eINSTANCE - .createValueType(); - value.setTextContent((String) dialog.getResultData()); - listEntries.getValue().add(value); - } else if (!isNullValue && dialog.isNullValue()) { - listEntries.getValue().remove(select); - NullValueType nullValue = FacesConfigFactory.eINSTANCE - .createNullValueType(); - listEntries.getNullValue().add(nullValue); - } else if (!isNullValue && !dialog.isNullValue()) { - ((ValueType) select).setTextContent((String) dialog - .getResultData()); - } - } - } - - private void removeButtonSelected() { - Object select = ((IStructuredSelection) tableViewer.getSelection()) - .getFirstElement(); - if (select instanceof NullValueType) - listEntries.getNullValue().remove(select); - else - listEntries.getValue().remove(select); - tableViewer.refresh(); - updateButtonsStatus(); - } - - public void updateButtonsStatus() { - if (((IStructuredSelection) tableViewer.getSelection()).size() > 0) { - editButton.setEnabled(true); - removeButton.setEnabled(true); - } else { - editButton.setEnabled(false); - removeButton.setEnabled(false); - } - } - - /** - * - */ - protected void okPressed() { - - String valueClass = valueClassField.getText(); - if (listEntries.getValueClass() != null) { - listEntries.getValueClass().setTextContent(valueClass); - } else { - ValueClassType valueClassType = FacesConfigFactory.eINSTANCE - .createValueClassType(); - valueClassType.setTextContent(valueClass); - listEntries.setValueClass(valueClassType); - } - super.okPressed(); - } - - /* - * @see org.eclipse.jface.window.Window#getInitialSize() - */ - protected Point getInitialSize() { - Point shellSize = super.getInitialSize(); - return new Point(Math.max( - convertHorizontalDLUsToPixels(MIN_DIALOG_WIDTH), shellSize.x), - shellSize.y); - } - - public IProject getProject() { - if (project == null) { - project = (IProject) section.getPage().getEditor().getAdapter( - IProject.class); - } - return project; - } - - public void setProject(IProject project) { - this.project = project; - } - - public ListEntriesType getListEntries() { - return listEntries; - } - - public void setListEntries(ListEntriesType listEntries) { - this.listEntries = listEntries; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/EditMapEntriesDialog.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/EditMapEntriesDialog.java deleted file mode 100644 index d03570a3b..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/EditMapEntriesDialog.java +++ /dev/null @@ -1,433 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.jst.jsf.facesconfig.ui.dialog; - -import org.eclipse.core.resources.IProject; -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.ClassButtonDialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogFieldBase; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.LayoutUtil; -import org.eclipse.jst.jsf.common.ui.internal.guiutils.SWTUtils; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.emf.KeyClassType; -import org.eclipse.jst.jsf.facesconfig.emf.KeyType; -import org.eclipse.jst.jsf.facesconfig.emf.MapEntriesType; -import org.eclipse.jst.jsf.facesconfig.emf.MapEntryType; -import org.eclipse.jst.jsf.facesconfig.emf.NullValueType; -import org.eclipse.jst.jsf.facesconfig.emf.ValueClassType; -import org.eclipse.jst.jsf.facesconfig.emf.ValueType; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.section.AbstractFacesConfigSection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.MouseAdapter; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; - -/** - * - * @author sfshi - * - */ -public class EditMapEntriesDialog extends Dialog { - - private static final int MIN_DIALOG_WIDTH = 300; - - private static final int TABLE_DEFAULT_HEIGHT = 160; - - private ClassButtonDialogField keyClassField; - - private ClassButtonDialogField valueClassField; - - private IProject project; - - private TableViewer tableViewer; - - private Button removeButton; - - private Button editButton; - - private MapEntriesType mapEntries; - - private AbstractFacesConfigSection section; - - /** - * - * @param parentShell - * @param mapEntries - * the map-entries element that working on. - */ - public EditMapEntriesDialog(Shell parentShell, MapEntriesType mapEntries, - AbstractFacesConfigSection section) { - super(parentShell); - this.mapEntries = mapEntries; - this.section = section; - } - - /* - * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) - */ - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - newShell.setText("Editing map-entries"); - } - - /* - * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) - */ - protected Control createDialogArea(Composite parent) { - Composite container = new Composite(parent, SWT.FILL); - GridData data = new GridData(GridData.FILL_BOTH); - container.setLayoutData(data); - - GridLayout gl = new GridLayout(); - gl.verticalSpacing = 0; - // gl.marginHeight = 0; - container.setLayout(gl); - createKeyValueSection(container); - createTableSection(container); - - initFields(); - return container; - } - - private void initFields() { - - if (mapEntries.getKeyClass() != null) - keyClassField.setText(mapEntries.getKeyClass().getTextContent()); - - if (mapEntries.getValueClass() != null) - valueClassField - .setText(mapEntries.getValueClass().getTextContent()); - - tableViewer.setInput(mapEntries); - } - - private void createKeyValueSection(Composite parent) { - keyClassField = new ClassButtonDialogField(getProject()); - keyClassField - .setLabelText(EditorMessages.InitializationSection_MapType_KeyClass);//$NON-NLS-1$ - - valueClassField = new ClassButtonDialogField(getProject()); - - valueClassField - .setLabelText(EditorMessages.InitializationSection_MapType_ValueClass);//$NON-NLS-1$ - - Composite typeSelectionSection = SWTUtils.createComposite(parent, - SWT.NONE); - - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - typeSelectionSection.setLayoutData(gd); - - int numberOfColumns = 4; - GridLayout gl = new GridLayout(numberOfColumns, false); - typeSelectionSection.setLayout(gl); - - keyClassField.doFillIntoGrid(null, typeSelectionSection, - numberOfColumns); - LayoutUtil.setHorizontalGrabbing(keyClassField.getTextControl(null, - parent)); - - valueClassField.doFillIntoGrid(null, typeSelectionSection, - numberOfColumns); - } - - /** - * - * @param parent - */ - private void createTableSection(Composite parent) { - Composite mapValueSection = SWTUtils.createComposite(parent, SWT.NONE); - - GridData gd = new GridData(GridData.FILL_BOTH); - mapValueSection.setLayoutData(gd); - - int numberOfColumns = 3; - GridLayout gl = new GridLayout(numberOfColumns, false); - mapValueSection.setLayout(gl); - - DialogField valuesTitle = new DialogFieldBase(); - valuesTitle - .setLabelText(EditorMessages.InitializationSection_MapTable_Title);//$NON-NLS-1$ - - valuesTitle.doFillIntoGrid(null, mapValueSection, numberOfColumns); - - Table mapTable = new Table(mapValueSection, SWT.FULL_SELECTION - | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); - - mapTable.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent e) { - updateButtonsStatus(); - - } - - }); - mapTable.addMouseListener(new MouseAdapter() { - public void mouseDoubleClick(MouseEvent e) { - if (((IStructuredSelection) tableViewer.getSelection()).size() > 0) - editButtonSelected(null); - } - }); - gd = new GridData(GridData.FILL_BOTH); - gd.horizontalSpan = 1; - gd.heightHint = TABLE_DEFAULT_HEIGHT; - mapTable.setLayoutData(gd); - mapTable.setHeaderVisible(true); - mapTable.setLinesVisible(true); - TableLayout layout = new TableLayout(); - mapTable.setLayout(layout); - - TableColumn keyCol = new TableColumn(mapTable, SWT.NONE); - keyCol - .setText(EditorMessages.InitializationSection_MapTable_Key);//$NON-NLS-1$ - layout.addColumnData(new ColumnWeightData(1, true)); - keyCol.setResizable(true); - - TableColumn valueCol = new TableColumn(mapTable, SWT.NONE); - layout.addColumnData(new ColumnWeightData(1, true)); - - valueCol - .setText(EditorMessages.InitializationSection_MapTable_Value);//$NON-NLS-1$ - valueCol.setResizable(true); - - tableViewer = new TableViewer(mapTable); - tableViewer.setContentProvider(new AdapterFactoryContentProvider( - getAdapterFactory())); - tableViewer.setLabelProvider(new AdapterFactoryLabelProvider( - getAdapterFactory())); - - tableViewer.addFilter(new ViewerFilter() { - public boolean select(Viewer viewer, Object parentElement, - Object element) { - return FacesConfigPackage.eINSTANCE.getMapEntryType() - .isInstance(element); - } - }); - - // map's operation buttons - Composite operationContainer = null; - - operationContainer = SWTUtils - .createComposite(mapValueSection, SWT.NONE); - - gd = new GridData(GridData.FILL_VERTICAL); - operationContainer.setLayoutData(gd); - gl = new GridLayout(); - operationContainer.setLayout(gl); - - Button addButton = SWTUtils.createPushButton(operationContainer, - EditorMessages.UI_Button_Add_more); //$NON-NLS-1$ - - gd = new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING); - gd.grabExcessHorizontalSpace = false; - addButton.setLayoutData(gd); - addButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - addButtonSelected(e); - } - }); - - editButton = SWTUtils.createPushButton(operationContainer, - EditorMessages.UI_Button_Edit_more); - - gd = new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING); - gd.grabExcessHorizontalSpace = false; - editButton.setLayoutData(gd); - editButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - editButtonSelected(e); - } - - }); - removeButton = SWTUtils.createPushButton(operationContainer, - EditorMessages.UI_Button_Remove); //$NON-NLS-1$ - - gd = new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING); - gd.grabExcessHorizontalSpace = false; - removeButton.setLayoutData(gd); - removeButton.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent e) { - removeButtonSelected(); - } - - }); - editButton.setEnabled(false); - removeButton.setEnabled(false); - } - - public IProject getProject() { - if (project == null) { - project = (IProject) section.getPage().getEditor().getAdapter( - IProject.class); - } - return project; - } - private AdapterFactory getAdapterFactory() { - return section.getAdapterFactory(); - } - - private void addButtonSelected(SelectionEvent e) { - AddEditMapEntryDialog dialog = new AddEditMapEntryDialog(EditorPlugin - .getActiveShell(), true); - if (dialog.open() == Dialog.OK) { - MapEntryType mapEntry = FacesConfigFactory.eINSTANCE - .createMapEntryType(); - if (dialog.getKey() != null) { - KeyType key = FacesConfigFactory.eINSTANCE.createKeyType(); - key.setTextContent(dialog.getKey()); - mapEntry.setKey(key); - } - if (dialog.isNullValue()) { - NullValueType nullValue = FacesConfigFactory.eINSTANCE - .createNullValueType(); - mapEntry.setNullValue(nullValue); - } else { - ValueType value = FacesConfigFactory.eINSTANCE - .createValueType(); - value.setTextContent(dialog.getValue()); - mapEntry.setValue(value); - } - - mapEntries.getMapEntry().add(mapEntry); - } - - } - - private void editButtonSelected(SelectionEvent e) { - MapEntryType mapEntry = (MapEntryType) ((IStructuredSelection) tableViewer - .getSelection()).getFirstElement(); - AddEditMapEntryDialog dialog = new AddEditMapEntryDialog(EditorPlugin - .getActiveShell(), false); - if (mapEntry.getKey() != null) - dialog.setKey(mapEntry.getKey().getTextContent()); - if (mapEntry.getNullValue() != null) - dialog.setNullValue(true); - else if (mapEntry.getValue() != null) - dialog.setValue(mapEntry.getValue().getTextContent()); - - if (dialog.open() == Dialog.OK) { - if (mapEntry.getKey() != null) - mapEntry.getKey().setTextContent(dialog.getKey()); - else { - KeyType keyType = FacesConfigFactory.eINSTANCE.createKeyType(); - keyType.setTextContent(dialog.getKey()); - mapEntry.setKey(keyType); - } - if (dialog.isNullValue()) { - if (mapEntry.getValue() != null) - EcoreUtil.remove(mapEntry.getValue()); - // mapEntry.eUnset(FacesConfigPackage.eINSTANCE.getMapEntryType_Value()); - mapEntry.setNullValue(FacesConfigFactory.eINSTANCE - .createNullValueType()); - - } else { - if (mapEntry.getNullValue() != null) - EcoreUtil.remove(mapEntry.getNullValue()); - if (mapEntry.getValue() != null) - mapEntry.getValue().setTextContent(dialog.getValue()); - else { - ValueType value = FacesConfigFactory.eINSTANCE - .createValueType(); - value.setTextContent(dialog.getValue()); - mapEntry.setValue(value); - } - - } - tableViewer.refresh(mapEntry); - } - - } - - private void removeButtonSelected() { - MapEntryType mapEntry = (MapEntryType) ((IStructuredSelection) tableViewer - .getSelection()).getFirstElement(); - mapEntries.getMapEntry().remove(mapEntry); - tableViewer.refresh(); - updateButtonsStatus(); - } - - public void updateButtonsStatus() { - if (((IStructuredSelection) tableViewer.getSelection()).size() > 0) { - editButton.setEnabled(true); - removeButton.setEnabled(true); - } else { - editButton.setEnabled(false); - removeButton.setEnabled(false); - } - } - - /** - * - */ - protected void okPressed() { - KeyClassType keyClass = FacesConfigFactory.eINSTANCE - .createKeyClassType(); - keyClass.setTextContent(this.keyClassField.getText().trim()); - mapEntries.setKeyClass(keyClass); - ValueClassType valueClass = FacesConfigFactory.eINSTANCE - .createValueClassType(); - valueClass.setTextContent(this.valueClassField.getText().trim()); - mapEntries.setValueClass(valueClass); - super.okPressed(); - } - - /* - * @see org.eclipse.jface.window.Window#getInitialSize() - */ - protected Point getInitialSize() { - Point shellSize = super.getInitialSize(); - return new Point(Math.max( - convertHorizontalDLUsToPixels(MIN_DIALOG_WIDTH), shellSize.x), - shellSize.y); - } - - public void setProject(IProject project) { - this.project = project; - } - - public MapEntriesType getMapEntries() { - return mapEntries; - } - - public void setMapEntries(MapEntriesType mapEntries) { - this.mapEntries = mapEntries; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/EditValueDialog.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/EditValueDialog.java deleted file mode 100644 index c6cdbb696..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/EditValueDialog.java +++ /dev/null @@ -1,208 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.dialog; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogFieldBase; -import org.eclipse.jst.jsf.common.ui.internal.guiutils.SWTUtils; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.jst.jsf.facesconfig.ui.IFacesConfigConstants; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; - -/** - * This dialog is used to edit managed bean's property. if the - * bDefinitionEditable is true, the property's name, class type, and initial - * value can be edit and changed. otherwise, only initial value can be changed. - * - * @author Xiao-guang Zhang, sfshi - */ -public class EditValueDialog extends Dialog { - - /** default dialog width and height */ - private static final int VALUE_WIDTH = 380; - - private static final int VALUE_HEIGHT = 220; - - private String value; - - /** property's initla value text control */ - private Text valueText; - - private Button nullValueTypeButton; - - private boolean isNullButtonShown = false; - - private boolean isNullValue; - - public EditValueDialog(Shell parentShell, String value) { - super(parentShell); - this.value = value; - this.isNullButtonShown = false; - } - - public EditValueDialog(Shell parentShell, boolean isNullButtonShown, - boolean isNullValue, String value) { - super(parentShell); - this.isNullValue = isNullValue; - this.value = value; - this.isNullButtonShown = isNullButtonShown; - } - - /* - * (non-Javadoc) - * - * @see Dialog#createDialogArea(Composite) - */ - protected Control createDialogArea(Composite parent) { - GridLayout gridLayout; - Composite container = (Composite) super.createDialogArea(parent); - gridLayout = new GridLayout(); - gridLayout.numColumns = 1; - gridLayout.marginHeight = 10; - gridLayout.marginWidth = 10; - container.setLayout(gridLayout); - GridData gd = new GridData(GridData.FILL_BOTH); - container.setLayoutData(gd); - - if (this.isNullButtonShown) { - nullValueTypeButton = SWTUtils.createCheckBox(container, - IFacesConfigConstants.NULL_VALUE, 2); - nullValueTypeButton.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent e) { - valueText.setEnabled(!nullValueTypeButton.getSelection()); - isNullValue = nullValueTypeButton.getSelection(); - } - - }); - } - - DialogField valueTitle = new DialogFieldBase(); - // ManagedBeansPage.ManagedBeanInitializationSection.MapTable.Title = - // Values: - valueTitle - .setLabelText(EditorMessages.ManagedBeanPropertyEditDialog_Value);//$NON-NLS-1$ - valueTitle.doFillIntoGrid(null, container, 1); - - gd = new GridData(GridData.FILL_BOTH); - gd.widthHint = VALUE_WIDTH; - gd.heightHint = VALUE_HEIGHT; - valueText = new Text(container, SWT.MULTI | SWT.BORDER); - valueText.setLayoutData(gd); - - initFields(); - return container; - } - - private void initFields() { - - if (isNullButtonShown && isNullValue) { - nullValueTypeButton.setSelection(true); - valueText.setEnabled(false); - } else if (value != null) { - valueText.setText(value); - } - } - - /** - * create a inital value group - * - * @param container - - * parent composite control - */ - protected void createValueSection(Composite container) { - Composite valueSection = new Composite(container, SWT.NONE); - GridLayout gl = new GridLayout(); - // gl.marginHeight = 20; - gl.numColumns = 2; - valueSection.setLayout(gl); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - valueSection.setLayoutData(gd); - - Label lblValue = new Label(valueSection, SWT.LEFT); - gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - gd.widthHint = 100; - lblValue.setLayoutData(gd); - - // ManagedBeanPropertyEditDialog.Value = Value: - lblValue - .setText(EditorMessages.ManagedBeanPropertyEditDialog_Value); //$NON-NLS-1$ - - gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL - | GridData.FILL_HORIZONTAL); - gd.widthHint = 200; - valueText = new Text(valueSection, SWT.BORDER); - valueText.setLayoutData(gd); - } - - /* - * (non-Javadoc) - * - * @see Dialog#createButtonsForButtonBar(Composite) - */ - protected void createButtonsForButtonBar(Composite parent) { - createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, - true); - createButton(parent, IDialogConstants.CANCEL_ID, - IDialogConstants.CANCEL_LABEL, false); - } - - /* - * (non-Javadoc) - * - * @see Dialog#configureShell(Shell) - */ - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - newShell.setText(EditorMessages.ValueEditDialog_Title); //$NON-NLS-1$ - } - - /* - * (non-Javadoc) - * - * @see Dialog#buttonPressed(int) - */ - protected void buttonPressed(int buttonId) { - if (buttonId == IDialogConstants.CANCEL_ID) { - setReturnCode(CANCEL); - close(); - return; - } else if (buttonId == IDialogConstants.OK_ID) { - value = valueText.getText(); - setReturnCode(OK); - close(); - return; - } - super.buttonPressed(buttonId); - } - - public Object getResultData() { - return value; - } - - public boolean isNullValue() { - return this.isNullButtonShown && isNullValue; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/ListChoiceDialog.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/ListChoiceDialog.java deleted file mode 100644 index e91881bb0..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/ListChoiceDialog.java +++ /dev/null @@ -1,116 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.dialog; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jst.jsf.common.ui.internal.guiutils.SWTUtils; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; - -/** - * @author Zhi-peng Zhang - * @version - */ -public class ListChoiceDialog extends Dialog { - /** The mini width for the text control */ - private static final int TEXT_MINI_WIDTH = 350; - - /** The mini width for the table viewer control */ - private static final int TABLEVIEWER_MINI_WIDTH = 200; - - private Text inputText; - - private TableViewer tableViewer; - - private String[] items; - - private String result; - - private String labelString; - - public ListChoiceDialog(Shell parentShell, String[] items, String labelString) { - super(parentShell); - this.items = items; - if(this.items == null) - { - this.items = new String[0]; - } - this.labelString = labelString; - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) - */ - protected Control createDialogArea(Composite parent) { - Composite composite = SWTUtils.createComposite(parent, 1); - - SWTUtils.createLabel(composite, labelString, 1); - - inputText = SWTUtils.createTextBox(composite, 1); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - gd.widthHint = TEXT_MINI_WIDTH; - inputText.setLayoutData(gd); - - inputText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - result = inputText.getText(); - } - }); - - createTableViewer(composite); - return composite; - } - - /** - * @param composite - */ - private void createTableViewer(Composite composite) { - tableViewer = new TableViewer(composite, SWT.BORDER | SWT.H_SCROLL - | SWT.V_SCROLL); - GridData gd = new GridData(GridData.FILL_BOTH); - gd.heightHint = TABLEVIEWER_MINI_WIDTH; - tableViewer.getControl().setLayoutData(gd); - tableViewer.add(items); - tableViewer - .addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - IStructuredSelection selection = (IStructuredSelection) event - .getSelection(); - if (selection != null) { - String text = (String) selection.getFirstElement(); - if (text != null && text.length() > 0) { - result = text; - inputText.setText(text); - } - } - } - }); - } - - public String getResult() - { - return result; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/LocaleDialog.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/LocaleDialog.java deleted file mode 100644 index 576401381..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/LocaleDialog.java +++ /dev/null @@ -1,181 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.dialog; - -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; - -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jst.jsf.common.ui.internal.guiutils.SWTUtils; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.KeyAdapter; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; - -/** - * @author Zhi-peng Zhang - * @version - */ -public class LocaleDialog extends StatusDialog { - private Text inputText; - - private TableViewer tableViewer; - - private String newLocale; - - private List existedLocaleList; - - private List itemsList; - - /** The mini width for the text control */ - private static final int TEXT_MINI_WIDTH = 350; - - /** The mini width for the table viewer control */ - private static final int TABLEVIEWER_MINI_WIDTH = 200; - - class LocaleViewerFilter extends ViewerFilter { - private String locale; - - LocaleViewerFilter(String locale) { - super(); - this.locale = locale; - } - - public boolean select(Viewer v, Object parent, Object object) { - if (object instanceof String) { - if (null == locale || locale.length() == 0) { - return true; - } - String aLocale = (String) object; - return aLocale.startsWith(this.locale); - } - return false; - } - } - - /** - * - * @param parentShell - * @param existedLocaleList - */ - public LocaleDialog(Shell parentShell, List existedLocaleList) { - super(parentShell); - this.existedLocaleList = existedLocaleList; - Locale[] locales = Locale.getAvailableLocales(); - itemsList = new ArrayList(locales.length); - - for (int i = 0, n = locales.length; i < n; i++) { - itemsList.add(locales[i].toString()); - } - - setStatusMessage(EditorMessages.LocaleConfigSection_Wizard_Page_AlreadyExistsError); - } - - /* - * (non-Javadoc) - * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) - */ - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - newShell.setText(EditorMessages.LocaleConfigSection_Wizard_WindowTitle); - } - - /* - * (non-Javadoc) - * @see org.eclipse.jst.jsf.facesconfig.ui.dialog.StatusDialog#createDialogContents(org.eclipse.swt.widgets.Composite) - */ - protected Control createDialogContents(Composite parent) { - GridLayout layout = new GridLayout(); - layout.marginWidth = 0; - layout.marginHeight = 0; - parent.setLayout(layout); - - SWTUtils - .createLabel( - parent, - EditorMessages.LocaleConfigSection_Wizard_Page_LabelText, - 1); - - inputText = SWTUtils.createTextBox(parent, 1); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - gd.widthHint = TEXT_MINI_WIDTH; - inputText.setLayoutData(gd); - - inputText.addKeyListener(new KeyAdapter() { - public void keyReleased(KeyEvent e) { - newLocale = inputText.getText(); - tableViewer.resetFilters(); - tableViewer.addFilter(new LocaleViewerFilter(newLocale)); - tableViewer.add(itemsList.toArray()); - updateStatus(); - } - }); - - createTableViewer(parent); - return parent; - } - - /** - * @param composite - */ - private void createTableViewer(Composite composite) { - tableViewer = new TableViewer(composite, SWT.BORDER | SWT.H_SCROLL - | SWT.V_SCROLL); - GridData gd = new GridData(GridData.FILL_BOTH); - gd.heightHint = TABLEVIEWER_MINI_WIDTH; - tableViewer.getControl().setLayoutData(gd); - tableViewer.add(itemsList.toArray()); - - tableViewer - .addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - - IStructuredSelection selection = (IStructuredSelection) event - .getSelection(); - if (selection != null) { - String text = (String) selection.getFirstElement(); - if (text != null && text.length() > 0) { - newLocale = text; - inputText.setText(text); - updateStatus(); - } - } - } - }); - - } - - protected boolean isValid() - { - if (existedLocaleList != null && existedLocaleList.contains(newLocale)) { - return false; - } - return true; - } - - public String getResult() - { - return newLocale; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/MessageBundleSelectionDialog.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/MessageBundleSelectionDialog.java deleted file mode 100644 index d4e34d862..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/MessageBundleSelectionDialog.java +++ /dev/null @@ -1,108 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.dialog; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jst.jsf.common.ui.IFileFolderConstants; -import org.eclipse.jst.jsf.common.ui.internal.dialogs.ResourceOnClasspathDialog; -import org.eclipse.jst.jsf.facesconfig.emf.MessageBundleType; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.swt.widgets.Shell; - -/** - * @author sfshi - * @version - */ -public class MessageBundleSelectionDialog extends ResourceOnClasspathDialog { - /** A list contains the resoursebundles existing in faces config */ - private List resourceBundles; - - private String selectPropertyFileMessage = EditorMessages.MessageBundleSection_Dialog_Message_SelectPropertyFile; - - private String alreadyExistStatusMessage = EditorMessages.MessageBundleSection_Dialog_Message_AlreadyExists; - - private static final String[] PROPERTIES_FILES_SUFFIXS = new String[] { IFileFolderConstants.EXT_PROPERTIES }; - - /** - * @param parentShell - * @param project - * @param resourceBundles - */ - public MessageBundleSelectionDialog(Shell parentShell, - IJavaProject project, List resourceBundles) { - super(parentShell, project); - this.resourceBundles = resourceBundles; - setSuffixs(PROPERTIES_FILES_SUFFIXS); - - setTitle(EditorMessages.MessageBundleSection_Dialog_Title); - setViewerSorter(new MessageBundleViewerSorter()); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogs.TreeViewerSelectionDialog#isValidSelection(java.lang.Object) - */ - protected boolean isValidSelection(Object selection) { - if (!(super.isValidSelection(selection))) { - setStatusMessage(selectPropertyFileMessage); - return false; - } - - List selectionList = new ArrayList(); - selectionList.add(selection); - this.setResult(selectionList); - Object result = super.getResult()[0]; - if (null == result) { - setStatusMessage(selectPropertyFileMessage); - return false; - } - - String newResourceBundle = (String) result; - - if (isAlreadyExist(newResourceBundle)) { - this.setStatusMessage(alreadyExistStatusMessage); - return false; - } - - return true; - } - - /** - * Determine whether this resource bundle file has already been defined in - * faces config. - * - * @return boolean - */ - private boolean isAlreadyExist(String resourceBundleString) { - if (null == resourceBundleString || resourceBundleString.length() == 0) { - return true; - } - - if (null == resourceBundles) { - return false; - } - - for (int i = 0; i < resourceBundles.size(); i++) { - MessageBundleType node = (MessageBundleType) resourceBundles.get(i); - String rbName = node.getTextContent(); - if (rbName != null && rbName.equalsIgnoreCase(resourceBundleString)) { - return true; - } - } - - return false; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/MessageBundleViewerSorter.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/MessageBundleViewerSorter.java deleted file mode 100644 index 0f18361f9..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/MessageBundleViewerSorter.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.dialog; - -import java.text.Collator; - -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.internal.core.JarPackageFragmentRoot; -import org.eclipse.jface.viewers.ViewerSorter; -import org.eclipse.jst.jsf.common.ui.IFileFolderConstants; - -/** - * @author sfshi - * @version - */ -public class MessageBundleViewerSorter extends ViewerSorter { - - /** - * - */ - public MessageBundleViewerSorter() { - super(); - } - - /** - * @param collator - */ - public MessageBundleViewerSorter(Collator collator) { - super(collator); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ViewerSorter#category(java.lang.Object) - */ - public int category(Object element) { - if (element instanceof IPackageFragmentRoot - && !(element instanceof JarPackageFragmentRoot)) { - IPackageFragmentRoot root = (IPackageFragmentRoot) element; - if (IFileFolderConstants.FOLDER_SOURCE - .equals(root.getElementName())) { - return 0; - } - return 1; - } - - return 2; - } -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/StatusDialog.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/StatusDialog.java deleted file mode 100644 index 5eec46153..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/dialog/StatusDialog.java +++ /dev/null @@ -1,114 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.dialog; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; - -/** - * @author Zhi-peng Zhang - * @version - */ - -/** - * A common Dialog with validation information. - */ -public abstract class StatusDialog extends Dialog { - /** The validation image */ - private Label statusImage; - - /** The validation message */ - private Label statusLabel; - - /** The validation message content */ - private String statusMessage; - - /** - * - * @param parentShell - */ - protected StatusDialog(Shell parentShell) { - super(parentShell); - } - - /** - * Creates and returns the contents of the upper part of this dialog (above - * the validation widgets). User should create Layout for the parent parameter. - * - * @param parent - * the parent composite to contain the dialog area - * @return the dialog area control - */ - protected abstract Control createDialogContents(Composite parent); - - /* - * (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) - */ - protected Control createDialogArea(Composite parent) { - Composite area = (Composite) super.createDialogArea(parent); - area.setLayout(new GridLayout(2,false)); - - Composite contents = new Composite(area, SWT.NONE); - GridData gd = new GridData(GridData.FILL_BOTH); - gd.horizontalSpan = 2; - contents.setLayoutData(gd); - createDialogContents(contents); - - statusImage = createLabel(area); - statusImage.setImage(JFaceResources - .getImage(Dialog.DLG_IMG_MESSAGE_ERROR)); - statusLabel = createLabel(area); - statusImage.setVisible(false); - return area; - } - - private Label createLabel(Composite parent) { - Label label = new Label(parent, SWT.LEFT); - GridData data = new GridData(); - data.horizontalSpan = 1; - data.horizontalAlignment = GridData.FILL; - label.setLayoutData(data); - return label; - } - - protected abstract boolean isValid(); - - protected void updateStatus() { - if (isValid()) { - statusImage.setVisible(false); - statusLabel.setText(""); //$NON-NLS-1$ - getButton(IDialogConstants.OK_ID).setEnabled(true); - } else { - statusImage.setVisible(true); - statusLabel.setText(statusMessage == null ? "" : statusMessage);//$NON-NLS-1$ - getButton(IDialogConstants.OK_ID).setEnabled(false); - } - } - - public String getStatusMessage() { - return statusMessage; - } - - public void setStatusMessage(String statusMessage) { - this.statusMessage = statusMessage; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/ComponentsPage.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/ComponentsPage.java deleted file mode 100644 index 1b4a7747e..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/ComponentsPage.java +++ /dev/null @@ -1,286 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.page; - -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jface.viewers.ViewerSorter; -import org.eclipse.jst.jsf.facesconfig.emf.AttributeType; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.emf.FacetType; -import org.eclipse.jst.jsf.facesconfig.emf.PropertyType; -import org.eclipse.jst.jsf.facesconfig.emf.RendererType; -import org.eclipse.jst.jsf.facesconfig.ui.FacesConfigEditor; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.jst.jsf.facesconfig.ui.page.detail.ComponentDetailsPage; -import org.eclipse.jst.jsf.facesconfig.ui.page.detail.ConverterDetailsPage; -import org.eclipse.jst.jsf.facesconfig.ui.page.detail.RenderkitDetailsPage; -import org.eclipse.jst.jsf.facesconfig.ui.page.detail.ValidatorDetailsPage; -import org.eclipse.jst.jsf.facesconfig.ui.section.ComponentMasterSection; -import org.eclipse.jst.jsf.facesconfig.ui.section.ConverterMasterSection; -import org.eclipse.jst.jsf.facesconfig.ui.section.FacesConfigMasterSection; -import org.eclipse.jst.jsf.facesconfig.ui.section.RenderkitMasterSection; -import org.eclipse.jst.jsf.facesconfig.ui.section.ValidatorMasterSection; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.forms.IDetailsPage; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.views.contentoutline.ContentOutlinePage; -import org.eclipse.ui.views.contentoutline.IContentOutlinePage; - -/** - * The "Components" page of faces config editor. - * - * @author sfshi - * - */ -public class ComponentsPage extends FacesConfigMasterDetailPage { - - /** - * The id of this page in the faces-config editor. - */ - public static final String PAGE_ID = "org.eclipse.jst.jsf.facesconfig.ui.page.ComponentsPage"; - - private IContentOutlinePage contentOutlinePage; - - /** - * Constructor of ComponentsPage; - * - * @param editor - * the facesconfig editor; - */ - public ComponentsPage(FacesConfigEditor editor) { - super(editor, "ComponentsPage", - EditorMessages.FacesConfigEditor_Components_TabName); - } - - /** - * Create the master sections; - * - * @see org.eclipse.jst.jsf.facesconfig.ui.page.FacesConfigMasterDetailPage#createMasterSections(Composite, - * IManagedForm, FormToolkit, FacesConfigMasterDetailPage) - */ - protected FacesConfigMasterSection[] createMasterSections( - Composite composite, IManagedForm managedForm, FormToolkit toolkit, - FacesConfigMasterDetailPage page) { - FacesConfigMasterSection componentMaster = new ComponentMasterSection( - composite, managedForm, toolkit, page); - componentMaster.getSection().setExpanded(true); - GridData gd = new GridData(GridData.FILL_BOTH); - componentMaster.getSection().setLayoutData(gd); - - FacesConfigMasterSection converterMaster = new ConverterMasterSection( - composite, managedForm, toolkit, page); - converterMaster.getSection().setExpanded(false); - GridData convertergd = new GridData(GridData.FILL_HORIZONTAL); - converterMaster.getSection().setLayoutData(convertergd); - - FacesConfigMasterSection renderkitMaster = new RenderkitMasterSection( - composite, managedForm, toolkit, page); - renderkitMaster.getSection().setExpanded(false); - GridData renderkitgd = new GridData(GridData.FILL_HORIZONTAL); - renderkitMaster.getSection().setLayoutData(renderkitgd); - - FacesConfigMasterSection validatorMaster = new ValidatorMasterSection( - composite, managedForm, toolkit, page); - validatorMaster.getSection().setExpanded(false); - GridData valicatorgd = new GridData(GridData.FILL_HORIZONTAL); - validatorMaster.getSection().setLayoutData(valicatorgd); - - return new FacesConfigMasterSection[] { componentMaster, - converterMaster, renderkitMaster, validatorMaster }; - } - - /** - * get the details page; - * - * @see org.eclipse.jst.jsf.facesconfig.ui.page.FacesConfigMasterDetailPage#getPageKey(Object - * object) - * @param key - * the eClass object of a component. - */ - public IDetailsPage getPage(Object key) { - IDetailsPage detailsPage = null; - if (key instanceof EClass) { - EClass eClass = (EClass) key; - if (eClass.getClassifierID() == FacesConfigPackage.COMPONENT_TYPE) { - detailsPage = new ComponentDetailsPage(this); - } else if (eClass.getClassifierID() == FacesConfigPackage.RENDER_KIT_TYPE) { - detailsPage = new RenderkitDetailsPage(this); - } else if (eClass.getClassifierID() == FacesConfigPackage.CONVERTER_TYPE) { - detailsPage = new ConverterDetailsPage(this); - } else if (eClass.getClassifierID() == FacesConfigPackage.VALIDATOR_TYPE) { - detailsPage = new ValidatorDetailsPage(this); - } - - if (detailsPage instanceof ISelectionProvider) { - ((ISelectionProvider) detailsPage) - .addSelectionChangedListener(this); - } - } - return detailsPage; - } - - public Object getAdapter(Class adapter) { - - if (adapter == IContentOutlinePage.class) { - return getOutlinePage(); - } - - return super.getAdapter(adapter); - } - - private IContentOutlinePage getOutlinePage() { - - if (contentOutlinePage == null) { - // The content outline is just a tree. - // - class ComponentsContentOutlinePage extends ContentOutlinePage { - public void createControl(Composite parent) { - super.createControl(parent); - TreeViewer contentOutlineViewer = getTreeViewer(); - contentOutlineViewer.addSelectionChangedListener(this); - - AdapterFactory adapterFactory = (AdapterFactory) getEditor() - .getAdapter(AdapterFactory.class); - // Set up the tree viewer. - contentOutlineViewer - .setContentProvider(new AdapterFactoryContentProvider( - adapterFactory)); - contentOutlineViewer - .setLabelProvider(new AdapterFactoryLabelProvider( - adapterFactory)); - contentOutlineViewer.addFilter(new ViewerFilter() { - - public boolean select(Viewer viewer, - Object parentElement, Object element) { - return FacesConfigPackage.eINSTANCE - .getComponentType().isInstance(element) - || FacesConfigPackage.eINSTANCE - .getConverterType().isInstance( - element) - || FacesConfigPackage.eINSTANCE - .getRenderKitType().isInstance( - element) - || FacesConfigPackage.eINSTANCE - .getValidatorType().isInstance( - element) - || FacesConfigPackage.eINSTANCE - .getAttributeType().isInstance( - element) - || FacesConfigPackage.eINSTANCE - .getPropertyType().isInstance( - element) - || FacesConfigPackage.eINSTANCE - .getFacetType().isInstance(element) - || FacesConfigPackage.eINSTANCE - .getRendererType().isInstance( - element); - } - }); - - contentOutlineViewer.setSorter(new ViewerSorter()); - contentOutlineViewer.setInput(getInput()); - } - - } - - contentOutlinePage = new ComponentsContentOutlinePage(); - - // Listen to selection so that we can handle it is a special - // way. - // - contentOutlinePage - .addSelectionChangedListener(new ISelectionChangedListener() { - // This ensures that we handle selections correctly. - public void selectionChanged(SelectionChangedEvent event) { - setSelection(event.getSelection()); - } - }); - - addSelectionChangedListener((ContentOutlinePage) contentOutlinePage); - } - - return contentOutlinePage; - - } - - /** - * handle the selection changed event from outline page. - * - * @param selection - */ - public void setSelection(ISelection selection) { - - if (selection instanceof IStructuredSelection) { - IStructuredSelection ss = (IStructuredSelection) selection; - IStructuredSelection currentSelection = (IStructuredSelection) this - .getSelection(); - if ((!ss.isEmpty()) - && (!currentSelection.isEmpty()) - && (ss.getFirstElement() == currentSelection - .getFirstElement())) { - return; - } - EObject component = null; - if (ss.getFirstElement() instanceof AttributeType - || ss.getFirstElement() instanceof PropertyType - || ss.getFirstElement() instanceof FacetType - || ss.getFirstElement() instanceof RendererType) { - component = ((EObject) ss.getFirstElement()).eContainer(); - } else if (ss.getFirstElement() instanceof EObject) { - component = (EObject) ss.getFirstElement(); - } - - if (component != null) { - FacesConfigMasterSection section = null; - if (FacesConfigPackage.eINSTANCE.getComponentType().isInstance( - component)) { - section = getFacesConfigMasterSections()[0]; - } else if (FacesConfigPackage.eINSTANCE.getConverterType() - .isInstance(component)) { - section = getFacesConfigMasterSections()[1]; - } else if (FacesConfigPackage.eINSTANCE.getRenderKitType() - .isInstance(component)) { - section = getFacesConfigMasterSections()[2]; - } else if (FacesConfigPackage.eINSTANCE.getValidatorType() - .isInstance(component)) { - section = getFacesConfigMasterSections()[3]; - } - - if (!section.getSection().isExpanded()) { - this.closeOtherSections(section); - GridData gd = new GridData(GridData.FILL_BOTH); - section.getSection().setLayoutData(gd); - section.getSection().setExpanded(true); - } - IStructuredSelection newselection = new StructuredSelection( - component); - section.getStructuredViewer().setSelection(newselection); - } - } - - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/FacesConfigMasterDetailPage.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/FacesConfigMasterDetailPage.java deleted file mode 100644 index 8a8224005..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/FacesConfigMasterDetailPage.java +++ /dev/null @@ -1,383 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.page; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain; -import org.eclipse.emf.edit.domain.EditingDomain; -import org.eclipse.emf.edit.domain.IEditingDomainProvider; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; -import org.eclipse.emf.edit.ui.view.ExtendedPropertySheetPage; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.FacesConfigEditor; -import org.eclipse.jst.jsf.facesconfig.ui.page.detail.FacesConfigDetailsPage; -import org.eclipse.jst.jsf.facesconfig.ui.section.FacesConfigMasterSection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.SashForm; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.forms.DetailsPart; -import org.eclipse.ui.forms.IDetailsPage; -import org.eclipse.ui.forms.IDetailsPageProvider; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.editor.FormPage; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.forms.widgets.ScrolledForm; -import org.eclipse.ui.views.properties.IPropertySheetPage; - -/** - * In some cases the page is a master-detail style, the content of the right - * side will change according user's selection on the left side. This is an - * abstract implementation of IFacesConfigPage, with a FacesConfigMasterSection - * array and a DetailsPart. - * - * @author sfshi - * - */ -public abstract class FacesConfigMasterDetailPage extends FormPage implements - IFacesConfigPage, IDetailsPageProvider, ISelectionChangedListener, - ISelectionProvider, IEditingDomainProvider { - - private final static Image BANNER_IMAGE = EditorPlugin.getDefault() - .getImage("form_banner.gif"); - - private FacesConfigMasterSection[] facesConfigMasterSections; - - private DetailsPart detailsPart; - - private Object input; - - private List selectionChangedListeners = new ArrayList(); - - private IPropertySheetPage propertySheetPage; - - private ISelection currentSelection = null; - - /** - * - * @param editor - * the editor part that this page belongs to; - * @param id - * page id; - * @param title - * page title; - */ - public FacesConfigMasterDetailPage(FacesConfigEditor editor, String id, - String title) { - super(editor, id, title); - } - - public EditingDomain getEditingDomain() { - return ((FacesConfigEditor) getEditor()).getEditingDomain(); - } - - /** - * - * @see org.eclipse.ui.forms.editor.FormPage#createFormContent(org.eclipse.ui.forms.IManagedForm) - */ - protected void createFormContent(IManagedForm managedForm) { - - ScrolledForm form = managedForm.getForm(); - form.setText(this.getTitle());//$NON-NLS-1$ - form.setBackgroundImage(BANNER_IMAGE); //$NON-NLS-1$ - fillBody(managedForm, managedForm.getToolkit()); - managedForm.refresh(); - } - - /** - * set input for this page when the it got activated at the first time; if - * it's not the first time, then refresh the page. - * - * @see org.eclipse.ui.forms.editor.FormPage#setActive(boolean) - */ - public void setActive(boolean active) { - super.setActive(active); - if (active) { - if (getInput() != ((FacesConfigEditor) getEditor()) - .getFacesConfig()) { - setInput(((FacesConfigEditor) getEditor()).getFacesConfig()); - } else { - this.refresh(); - } - } - } - - public boolean isEditor() { - return true; - } - - /** - * - * @param managedForm - * @param toolkit - */ - private void fillBody(IManagedForm managedForm, FormToolkit toolkit) { - Composite body = managedForm.getForm().getBody(); - - GridLayout gridLayout = new GridLayout(); - gridLayout.horizontalSpacing = 0; - gridLayout.verticalSpacing = 0; - gridLayout.numColumns = 2; - gridLayout.marginHeight = 0; - gridLayout.marginWidth = 0; - body.setLayout(gridLayout); - - SashForm sashForm = new SashForm(body, SWT.NULL); - managedForm.getToolkit().adapt(sashForm, false, false); - sashForm.setMenu(body.getMenu()); - sashForm.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Composite leftContainer = toolkit.createComposite(sashForm); - GridLayout gl = new GridLayout(); - gl.marginHeight = 0; - leftContainer.setLayout(gl); - - // create master sections here - facesConfigMasterSections = createMasterSections(leftContainer, - managedForm, toolkit, this); - - if (facesConfigMasterSections != null) { - for (int i = 0, n = facesConfigMasterSections.length; i < n; i++) { - FacesConfigMasterSection aSection = facesConfigMasterSections[i]; - aSection.initialize(); - aSection.addSelectionChangedListener(this); - - } - } - - detailsPart = new DetailsPart(managedForm, sashForm, SWT.NULL); - managedForm.addPart(detailsPart); - - detailsPart.setPageLimit(4); - detailsPart.setPageProvider(this); - - detailsPart.initialize(managedForm); - - sashForm.setWeights(new int[] { 40, 60 }); - - getSite().setSelectionProvider(this); - } - - /** - * Create the detail sections, and set layout data and initial expand state - * for them. - * - * @param composite - * @param managedForm - * @param toolkit - * @param page - * @return the detail sections - */ - abstract protected FacesConfigMasterSection[] createMasterSections( - Composite composite, IManagedForm managedForm, FormToolkit toolkit, - FacesConfigMasterDetailPage page); - - /** - * set input object; also set into all the master sections. - */ - public void setInput(Object input) { - if (facesConfigMasterSections != null) { - for (int i = 0, n = facesConfigMasterSections.length; i < n; i++) { - facesConfigMasterSections[i].setInput(input); - } - } - this.input = input; - } - - /** - * get the input object. - */ - public Object getInput() { - return input; - } - - /** - * Defaultly use the EClass object of the selected object as page key. Sub - * classes can override this method if there has other ways. - * - * @param object - */ - public Object getPageKey(Object object) { - if (object instanceof EObject) { - EObject eObject = (EObject) object; - return eObject.eClass(); - } - return null; - } - - /** - * Subclasses should create and return an IDetailsPage instance according - * what the key is. Defaultly the EClass object of the selected object in - * the structured viewer will be taken as the page key. - * - * @see #getPageKey - * - */ - abstract public IDetailsPage getPage(Object key); - - /** - * transfer the selection changed event to detail part. - */ - public void selectionChanged(SelectionChangedEvent event) { - - currentSelection = event.getSelection(); - if (event.getSource() instanceof FacesConfigMasterSection) { - FacesConfigMasterSection source = (FacesConfigMasterSection) event - .getSource(); - - detailsPart.selectionChanged(source, event.getSelection()); - - if (source.getSection().isExpanded()) { - for (int i = 0, n = selectionChangedListeners.size(); i < n; i++) { - ((ISelectionChangedListener) selectionChangedListeners - .get(i)).selectionChanged(event); - } - } - } else if (event.getSource() instanceof FacesConfigDetailsPage) { - for (int i = 0, n = selectionChangedListeners.size(); i < n; i++) { - ((ISelectionChangedListener) selectionChangedListeners.get(i)) - .selectionChanged(event); - } - } - } - - /** - * set other sections' expand state to false, except this section; - * - * @param section - * the section that be expanded. - */ - public void closeOtherSections(FacesConfigMasterSection section) { - - for (int i = 0, n = facesConfigMasterSections.length; i < n; i++) { - FacesConfigMasterSection aSection = facesConfigMasterSections[i]; - if (aSection != section && aSection.getSection().isExpanded()) { - aSection.getSection().setExpanded(false); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - aSection.getSection().setLayoutData(gd); - } - } - } - - /** - * refresh this page, the expanded section and the detail page will got - * refreshed. - */ - public void refresh() { - - // only refresh the expanded section; - for (int i = 0, n = facesConfigMasterSections.length; i < n; i++) { - if (facesConfigMasterSections[i].getSection().isExpanded()) { - facesConfigMasterSections[i].refresh(); - } - } - - // refresh the detail page, it will call detail sections - // to got refreshed. - if (detailsPart.getCurrentPage() != null) { - detailsPart.getCurrentPage().refresh(); - } - } - - /** - * get the section that is expanded. - * - * @return the master section - */ - protected FacesConfigMasterSection getActiveSection() { - for (int i = 0, n = facesConfigMasterSections.length; i < n; i++) { - - if (facesConfigMasterSections[i].getSection().isExpanded()) { - return facesConfigMasterSections[i]; - } - } - return null; - - } - - public void addSelectionChangedListener(ISelectionChangedListener listener) { - selectionChangedListeners.add(listener); - } - - public ISelection getSelection() { - if(currentSelection != null) - return currentSelection; - return StructuredSelection.EMPTY; - - } - - public void removeSelectionChangedListener( - ISelectionChangedListener listener) { - selectionChangedListeners.remove(listener); - } - - public void setSelection(ISelection selection) { - // no selection setting - } - - public Object getAdapter(Class adapter) { - - if (adapter == IPropertySheetPage.class) { - return getPropertySheetPage(); - } - return super.getAdapter(adapter); - } - - private IPropertySheetPage getPropertySheetPage() { - - AdapterFactoryEditingDomain editingDomain = (AdapterFactoryEditingDomain) getEditor() - .getAdapter(EditingDomain.class); - AdapterFactory adapterFactory = (AdapterFactory) getEditor() - .getAdapter(AdapterFactory.class); - if (propertySheetPage == null) { - propertySheetPage = new ExtendedPropertySheetPage(editingDomain) { - public void setSelectionToViewer(List selection) { - // FacesConfigEditor.this.setSelectionToViewer(selection); - // FacesConfigEditor.this.setFocus(); - } - - public void setActionBars(IActionBars actionBars) { - super.setActionBars(actionBars); - // getActionBarContributor().shareGlobalActions(this, - // actionBars); - } - }; - ((ExtendedPropertySheetPage) propertySheetPage) - .setPropertySourceProvider(new AdapterFactoryContentProvider( - adapterFactory)); - // this.addSelectionChangedListener((ExtendedPropertySheetPage) - // propertySheetPage); - } - - return propertySheetPage; - - } - - /** - * @return the facesConfigMasterSections - */ - public FacesConfigMasterSection[] getFacesConfigMasterSections() { - return facesConfigMasterSections; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/IFacesConfigPage.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/IFacesConfigPage.java deleted file mode 100644 index 42afa4ff8..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/IFacesConfigPage.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.page; - -import org.eclipse.ui.forms.editor.IFormPage; - -/** - * Implemented by IFormPage's that want to support EditorInput-like - * model set/get/refresh - * - * @author sfshi - * - */ -public interface IFacesConfigPage extends IFormPage { - - /** - * Set the input. Implementer may choose to ignore - * - * @param input - */ - void setInput(Object input); - - /** - * @return the input or null if none set - */ - Object getInput(); - - /** - * signal to a form page that the data in its input has changed - * and it should refresh its view. - */ - void refresh(); - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/IntroductionPage.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/IntroductionPage.java deleted file mode 100644 index 3b12b6a13..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/IntroductionPage.java +++ /dev/null @@ -1,131 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.page; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jst.jsf.common.ui.internal.guiutils.IntroductionSection; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.FacesConfigEditor; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.editor.FormPage; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.forms.widgets.ScrolledForm; -import org.eclipse.ui.forms.widgets.TableWrapData; -import org.eclipse.ui.forms.widgets.TableWrapLayout; - -/** - * Handle the Introduction page for the pageflow editor. - * - * @author jchoi - */ -public class IntroductionPage extends FormPage implements IFacesConfigPage, ISelectionProvider{ - /** - * @param facesConfigEditor - */ - public IntroductionPage(FacesConfigEditor facesConfigEditor) { - super(facesConfigEditor, IntroductionPage.class.getName(), - EditorMessages.editor_pageflow_page_intro_name); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.forms.editor.FormPage#createFormContent(org.eclipse.ui.forms.IManagedForm) - */ - protected void createFormContent(IManagedForm managedForm) { - // get the form - ScrolledForm form = managedForm.getForm(); - FormToolkit toolkit = getEditor().getToolkit(); - form.setText(EditorMessages.editor_pageflow_page_intro_title); - - form.setBackgroundImage(EditorPlugin.getDefault().getImage("form_banner.gif")); - - // create a layout - TableWrapLayout layout = new TableWrapLayout(); - layout.numColumns = 1; - layout.makeColumnsEqualWidth = true; - form.getBody().setLayout(layout); - - IntroductionSection introPart = new IntroductionSection( - FacesConfigEditor.EDITOR_ID, managedForm, toolkit, - EditorMessages.editor_pageflow_page_intro_help_HelpContextID, - EditorMessages.editor_pageflow_page_intro_help_HelpToolTip); - - TableWrapData td = new TableWrapData(TableWrapData.FILL_GRAB); - td.colspan = 1; - introPart.setLayoutData(td); - - getSite().setSelectionProvider(this); - } - - public void addSelectionChangedListener(ISelectionChangedListener listener) { - // TODO Auto-generated method stub - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.forms.editor.IFormPage#isEditor() - */ - public boolean isEditor() { - return true; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection() - */ - public ISelection getSelection() { - return StructuredSelection.EMPTY; - } - - public void removeSelectionChangedListener(ISelectionChangedListener listener) { - // TODO Auto-generated method stub - - } - - public void setSelection(ISelection selection) { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.facesconfig.ui.page.IFacesConfigPage#getInput() - */ - public Object getInput() { - // TODO Auto-generated method stub - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.facesconfig.ui.page.IFacesConfigPage#refresh() - */ - public void refresh() { - // TODO Auto-generated method stub - - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.facesconfig.ui.page.IFacesConfigPage#setInput(java.lang.Object) - */ - public void setInput(Object input) { - // TODO Auto-generated method stub - - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/ManagedBeanPage.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/ManagedBeanPage.java deleted file mode 100644 index cc092c041..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/ManagedBeanPage.java +++ /dev/null @@ -1,198 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.page; - -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jface.viewers.ViewerSorter; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanType; -import org.eclipse.jst.jsf.facesconfig.emf.ManagedPropertyType; -import org.eclipse.jst.jsf.facesconfig.ui.FacesConfigEditor; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.jst.jsf.facesconfig.ui.page.detail.ManagedBeanDetailsPage; -import org.eclipse.jst.jsf.facesconfig.ui.section.FacesConfigMasterSection; -import org.eclipse.jst.jsf.facesconfig.ui.section.ManagedBeanMasterSection; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.forms.IDetailsPage; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.views.contentoutline.ContentOutlinePage; -import org.eclipse.ui.views.contentoutline.IContentOutlinePage; - -/** - * - * @author sfshi - * - */ -public class ManagedBeanPage extends FacesConfigMasterDetailPage { - - /** - * The id of this page in the faces-config editor. - */ - public static final String PAGE_ID = "org.eclipse.jst.jsf.facesconfig.ui.page.ManagedBeanPage"; - - private IContentOutlinePage contentOutlinePage; - - /** - * @param editor - */ - public ManagedBeanPage(FacesConfigEditor editor) { - super(editor, "ManagedBeanPage", - EditorMessages.FacesConfigEditor_ManagedBeans_TabName); - } - - protected FacesConfigMasterSection[] createMasterSections( - Composite composite, IManagedForm managedForm, FormToolkit toolkit, - FacesConfigMasterDetailPage page) { - FacesConfigMasterSection managedBeanMaster = new ManagedBeanMasterSection( - composite, managedForm, toolkit, page); - managedBeanMaster.getSection().setExpanded(true); - GridData gd = new GridData(GridData.FILL_BOTH); - managedBeanMaster.getSection().setLayoutData(gd); - return new FacesConfigMasterSection[] { managedBeanMaster }; - } - - public IDetailsPage getPage(Object key) { - IDetailsPage detailsPage = null; - if (key instanceof EClass) { - EClass eClass = (EClass) key; - if (eClass.getClassifierID() == FacesConfigPackage.MANAGED_BEAN_TYPE) { - detailsPage = new ManagedBeanDetailsPage(this); - } - - if (detailsPage instanceof ISelectionProvider) { - ((ISelectionProvider) detailsPage) - .addSelectionChangedListener(this); - } - } - return detailsPage; - } - - public Object getAdapter(Class adapter) { - - if (adapter == IContentOutlinePage.class) { - return getOutlinePage(); - } - - return super.getAdapter(adapter); - } - - private IContentOutlinePage getOutlinePage() { - - if (contentOutlinePage == null) { - // The content outline is just a tree. - // - class ManagedBeanContentOutlinePage extends ContentOutlinePage { - public void createControl(Composite parent) { - super.createControl(parent); - TreeViewer contentOutlineViewer = getTreeViewer(); - contentOutlineViewer.addSelectionChangedListener(this); - - AdapterFactory adapterFactory = (AdapterFactory) getEditor() - .getAdapter(AdapterFactory.class); - // Set up the tree viewer. - contentOutlineViewer - .setContentProvider(new AdapterFactoryContentProvider( - adapterFactory)); - contentOutlineViewer - .setLabelProvider(new AdapterFactoryLabelProvider( - adapterFactory)); - contentOutlineViewer.addFilter(new ViewerFilter() { - - public boolean select(Viewer viewer, - Object parentElement, Object element) { - return FacesConfigPackage.eINSTANCE - .getManagedBeanType().isInstance(element) - || FacesConfigPackage.eINSTANCE - .getManagedPropertyType() - .isInstance(element); - } - }); - - contentOutlineViewer.setSorter(new ViewerSorter()); - contentOutlineViewer.setInput(getInput()); - } - - } - - contentOutlinePage = new ManagedBeanContentOutlinePage(); - - // Listen to selection so that we can handle it is a special - // way. - // - contentOutlinePage - .addSelectionChangedListener(new ISelectionChangedListener() { - // This ensures that we handle selections correctly. - public void selectionChanged(SelectionChangedEvent event) { - setSelection(event.getSelection()); - } - }); - - // this.addSelectionChangedListener((ContentOutlinePage) - // contentOutlinePage); - } - - return contentOutlinePage; - - } - - /** - * handle the selection changed event from outline page. - * - * @param selection - */ - public void setSelection(ISelection selection) { - - if (selection instanceof IStructuredSelection) { - IStructuredSelection ss = (IStructuredSelection) selection; - ManagedBeanType bean = null; - if (ss.getFirstElement() instanceof ManagedBeanType) { - bean = (ManagedBeanType) ss.getFirstElement(); - } else if (ss.getFirstElement() instanceof ManagedPropertyType) { - bean = (ManagedBeanType) ((ManagedPropertyType) ss - .getFirstElement()).eContainer(); - } - - if (bean != null) { - if (!getManagedBeanMasterSection().getSection().isExpanded()) { - GridData gd = new GridData(GridData.FILL_BOTH); - getManagedBeanMasterSection().getSection() - .setLayoutData(gd); - getManagedBeanMasterSection().getSection() - .setExpanded(true); - } - IStructuredSelection newselection = new StructuredSelection( - bean); - getManagedBeanMasterSection().getStructuredViewer() - .setSelection(newselection); - } - } - - } - - private ManagedBeanMasterSection getManagedBeanMasterSection() { - return (ManagedBeanMasterSection) getFacesConfigMasterSections()[0]; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/OthersPage.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/OthersPage.java deleted file mode 100644 index b0026c941..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/OthersPage.java +++ /dev/null @@ -1,763 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.page; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.impl.AdapterImpl; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain; -import org.eclipse.emf.edit.domain.EditingDomain; -import org.eclipse.emf.edit.domain.IEditingDomainProvider; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; -import org.eclipse.emf.edit.ui.view.ExtendedPropertySheetPage; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jface.viewers.ViewerSorter; -import org.eclipse.jst.jsf.facesconfig.emf.ApplicationType; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigType; -import org.eclipse.jst.jsf.facesconfig.emf.FactoryType; -import org.eclipse.jst.jsf.facesconfig.emf.LifecycleType; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.FacesConfigEditor; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.jst.jsf.facesconfig.ui.section.AbstractFacesConfigSection; -import org.eclipse.jst.jsf.facesconfig.ui.section.ApplicationSection; -import org.eclipse.jst.jsf.facesconfig.ui.section.FactorySection; -import org.eclipse.jst.jsf.facesconfig.ui.section.LifecycleSection; -import org.eclipse.jst.jsf.facesconfig.ui.section.LocaleConfigSection; -import org.eclipse.jst.jsf.facesconfig.ui.section.OthersPageBaseSection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.SashForm; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.editor.FormPage; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.forms.widgets.ScrolledForm; -import org.eclipse.ui.views.contentoutline.ContentOutlinePage; -import org.eclipse.ui.views.contentoutline.IContentOutlinePage; -import org.eclipse.ui.views.properties.IPropertySheetPage; - -/** - * @author Zhi-peng Zhang, sfshi - * @version - */ - -/** - * This class is the "Others" page. - */ -public class OthersPage extends FormPage implements IFacesConfigPage, - ISelectionProvider, ISelectionChangedListener, IEditingDomainProvider { - - /** - * The id of this page in the faces-config editor. - */ - public static final String PAGE_ID = "org.eclipse.jst.jsf.facesconfig.ui.page.OthersPage"; - - private final static Image BANNER_IMAGE = EditorPlugin.getDefault() - .getImage("form_banner.gif"); - - private List leftSections; - - private List rightSections; - - private Object input; - - private List selectionChangedListeners = new ArrayList(); - - private IPropertySheetPage propertySheetPage; - - private IContentOutlinePage contentOutlinePage; - - private ISelection currentSelection; - - /** - * Constructor of OthersPage; - * - * @param editor - * the facesconfig editor; - */ - public OthersPage(FacesConfigEditor editor) { - super(editor, "OthersPage", - EditorMessages.FacesConfigEditor_Others_TabName); - } - - protected void createFormContent(IManagedForm managedForm) { - super.createFormContent(managedForm); - ScrolledForm form = managedForm.getForm(); - form.setText(EditorMessages.OthersPage_Title); - form.setBackgroundImage(BANNER_IMAGE); - fillBody(managedForm, managedForm.getToolkit()); - managedForm.refresh(); - } - - private void initSection(OthersPageBaseSection section, String name, - String description, ArrayList list) { - section.getSection().setText(name); - section.getSection().setDescription(description); - section.initialize(); - section.addSelectionChangedListener(this); - section.getSection().setExpanded(false); - section.getSection().setLayoutData( - new GridData(GridData.FILL_HORIZONTAL)); - list.add(section); - } - - private void fillBody(IManagedForm managedForm, FormToolkit toolkit) { - Composite body = managedForm.getForm().getBody(); - - body.setLayout(new GridLayout()); - - SashForm sashForm = new SashForm(body, SWT.NONE); - managedForm.getToolkit().adapt(sashForm, false, false); - sashForm.setMenu(body.getMenu()); - sashForm.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Composite leftContainer = toolkit.createComposite(sashForm); - leftContainer.setLayout(new GridLayout()); - - ArrayList sectionList = new ArrayList(); - - OthersPageBaseSection section = new ApplicationSection( - FacesConfigPackage.eINSTANCE.getActionListenerType(), - leftContainer, managedForm, this, toolkit); - initSection(section, EditorMessages.ActionListenerSection_Name, - EditorMessages.ActionListenerSection_Description, - sectionList); - section.getSection().setLayoutData(new GridData(GridData.FILL_BOTH)); - section.getSection().setExpanded(true); - - section = new ApplicationSection(FacesConfigPackage.eINSTANCE - .getDefaultRenderKitIdType(), leftContainer, managedForm, this, - toolkit); - initSection(section, - EditorMessages.DefaultRenderKitIDSection_Name, - EditorMessages.DefaultRenderKitIDSection_Description, - sectionList); - - section = new LocaleConfigSection(FacesConfigPackage.eINSTANCE - .getSupportedLocaleType(), leftContainer, managedForm, this, - toolkit); - initSection(section, EditorMessages.LocaleConfigSection_Name, - EditorMessages.LocaleConfigSection_Description, - sectionList); - - section = new ApplicationSection(FacesConfigPackage.eINSTANCE - .getMessageBundleType(), leftContainer, managedForm, this, - toolkit); - initSection(section, EditorMessages.MessageBundleSection_Name, - EditorMessages.MessageBundleSection_Description, - sectionList); - - section = new ApplicationSection(FacesConfigPackage.eINSTANCE - .getNavigationHandlerType(), leftContainer, managedForm, this, - toolkit); - initSection(section, - EditorMessages.NavigationHandlerSection_Name, - EditorMessages.NavigationHandlerSection_Description, - sectionList); - - section = new ApplicationSection(FacesConfigPackage.eINSTANCE - .getPropertyResolverType(), leftContainer, managedForm, this, - toolkit); - initSection(section, - EditorMessages.PropertyResolverSection_Name, - EditorMessages.PropertyResolverSection_Description, - sectionList); - - section = new ApplicationSection(FacesConfigPackage.eINSTANCE - .getStateManagerType(), leftContainer, managedForm, this, - toolkit); - initSection(section, EditorMessages.StateManagerSection_Name, - EditorMessages.StateManagerSection_Description, - sectionList); - - section = new ApplicationSection(FacesConfigPackage.eINSTANCE - .getVariableResolverType(), leftContainer, managedForm, this, - toolkit); - initSection(section, - EditorMessages.VariableResolverSection_Name, - EditorMessages.VariableResolverSection_Description, - sectionList); - - section = new ApplicationSection(FacesConfigPackage.eINSTANCE - .getViewHandlerType(), leftContainer, managedForm, this, - toolkit); - initSection(section, EditorMessages.ViewHandlerSection_Name, - EditorMessages.ViewHandlerSection_Description, - sectionList); - - leftSections = sectionList; - - sectionList = new ArrayList(); - - Composite rightContainer = toolkit.createComposite(sashForm); - rightContainer.setLayout(new GridLayout()); - rightContainer.setLayoutData(new GridData(GridData.FILL_BOTH)); - - section = new FactorySection(FacesConfigPackage.eINSTANCE - .getApplicationFactoryType(), rightContainer, managedForm, - this, toolkit); - initSection(section, - EditorMessages.ApplicationFactorySection_Name, - EditorMessages.ApplicationFactorySection_Description, - sectionList); - section.getSection().setLayoutData(new GridData(GridData.FILL_BOTH)); - section.getSection().setExpanded(true); - - section = new FactorySection(FacesConfigPackage.eINSTANCE - .getFacesContextFactoryType(), rightContainer, managedForm, - this, toolkit); - initSection(section, - EditorMessages.FacesContextFactorySection_Name, - EditorMessages.FacesContextFactorySection_Description, - sectionList); - - section = new FactorySection(FacesConfigPackage.eINSTANCE - .getLifecycleFactoryType(), rightContainer, managedForm, this, - toolkit); - initSection(section, - EditorMessages.LifecycleFactorySection_Name, - EditorMessages.LifecycleFactorySection_Description, - sectionList); - - section = new FactorySection(FacesConfigPackage.eINSTANCE - .getRenderKitFactoryType(), rightContainer, managedForm, this, - toolkit); - initSection(section, - EditorMessages.RenderKitFactorySection_Name, - EditorMessages.RenderKitFactorySection_Description, - sectionList); - - section = new LifecycleSection(FacesConfigPackage.eINSTANCE - .getPhaseListenerType(), rightContainer, managedForm, this, - toolkit); - initSection(section, EditorMessages.PhaseListenerSection_Name, - EditorMessages.PhaseListenerSection_Description, - sectionList); - - rightSections = sectionList; - - getSite().setSelectionProvider(this); - } - - /** - * set input for this page when the it got activated at the first time; if - * it's not the first time, then refresh the page. - * - * @see org.eclipse.ui.forms.editor.FormPage#setActive(boolean) - */ - public void setActive(boolean active) { - super.setActive(active); - if (active) { - if (getInput() != ((FacesConfigEditor) getEditor()) - .getFacesConfig()) { - setInput(((FacesConfigEditor) getEditor()).getFacesConfig()); - } else { - this.refresh(); - } - } - } - - /** - * - */ - public void setInput(Object input) { - if (input instanceof FacesConfigType) { - this.input = input; - FacesConfigType facesConfig = (FacesConfigType) input; - facesConfig.eAdapters().add(new FacesConfigOthersAdapter()); - setInputForApplicationSections(facesConfig); - setInputForFactorySections(facesConfig); - setInputForLifecycleSections(facesConfig); - } - } - - public boolean isEditor() { - return true; - } - - /** - * Reset the editor input for the application section - */ - public void resetApplicationInput() { - if (getInput() instanceof FacesConfigType) { - setInputForApplicationSections((FacesConfigType) getInput()); - } - } - - /** - * Reset the editor input for the factory sections - */ - public void resetFactoryInput() { - if (getInput() instanceof FacesConfigType) { - setInputForFactorySections((FacesConfigType) getInput()); - } - } - - /** - * Reset the editor input for the lifecycle section - */ - public void resetLifecycleInput() { - if (getInput() instanceof FacesConfigType) { - setInputForLifecycleSections((FacesConfigType) getInput()); - } - } - - /** - * Sets the model for all Application sub-model elements to facesConfig - * @param facesConfig - */ - protected void setInputForApplicationSections(FacesConfigType facesConfig) { - ApplicationType application; - if (facesConfig.getApplication().size() > 0) { - application = (ApplicationType) facesConfig.getApplication().get(0); - } else { - application = null; - } - for (Iterator it = leftSections.iterator(); it.hasNext();) { - ApplicationSection section = (ApplicationSection) it.next(); - section.setInput(application); - } - } - - /** - * Sets the model for all Factory sub-model elements to facesConfig - * @param facesConfig - */ - protected void setInputForFactorySections(FacesConfigType facesConfig) { - FactoryType factory; - if (facesConfig.getFactory().size() > 0) { - factory = (FactoryType) facesConfig.getFactory().get(0); - } else { - factory = null; - } - - for (Iterator it = rightSections.iterator(); it.hasNext();) { - Object section = it.next(); - if (section instanceof FactorySection) - ((FactorySection) section).setInput(factory); - } - } - - /** - * Sets the model for all Lifecycle sub-model elements to facesConfig - * @param facesConfig - */ - protected void setInputForLifecycleSections(FacesConfigType facesConfig) { - LifecycleType lifecycle; - if (facesConfig.getLifecycle().size() > 0) { - lifecycle = (LifecycleType) facesConfig.getLifecycle().get(0); - - } else { - lifecycle = null; - } - for (Iterator it = rightSections.iterator(); it.hasNext();) { - Object section = it.next(); - if (section instanceof LifecycleSection) - ((LifecycleSection) section).setInput(lifecycle); - } - } - - public Object getInput() { - return input; - } - - public void refresh() { - - // only refresh the expanded section; - for (int i = 0, n = leftSections.size(); i < n; i++) { - OthersPageBaseSection section = (OthersPageBaseSection) leftSections - .get(i); - if (section.getSection().isExpanded()) { - section.refresh(); - } - } - - for (int i = 0, n = rightSections.size(); i < n; i++) { - OthersPageBaseSection section = (OthersPageBaseSection) leftSections - .get(i); - if (section.getSection().isExpanded()) { - section.refresh(); - } - } - - } - - /** - * set other sections' expand state to false, except this section; - * - * @param section - * the section that be expanded. - */ - public void closeOtherSections(AbstractFacesConfigSection section) { - OthersPageBaseSection[] sections; - if (leftSections.contains(section)) { - sections = (OthersPageBaseSection[]) leftSections - .toArray(new OthersPageBaseSection[leftSections.size()]); - } else { - sections = (OthersPageBaseSection[]) rightSections - .toArray(new OthersPageBaseSection[rightSections.size()]); - } - for (int i = 0, n = sections.length; i < n; i++) { - AbstractFacesConfigSection aSection = sections[i]; - if (aSection != section && aSection.getSection().isExpanded()) { - aSection.getSection().setExpanded(false); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - aSection.getSection().setLayoutData(gd); - } - } - } - - /** - * An adapter on faces config. - * - * @author sfshi - * - */ - class FacesConfigOthersAdapter extends AdapterImpl { - public void notifyChanged(Notification msg) { - if (msg.getEventType() == Notification.REMOVE - || msg.getEventType() == Notification.ADD) { - if (msg.getFeature() == FacesConfigPackage.eINSTANCE - .getFacesConfigType_Application()) { - resetApplicationInput(); - } else if (msg.getFeature() == FacesConfigPackage.eINSTANCE - .getFacesConfigType_Factory()) { - resetFactoryInput(); - } else if (msg.getFeature() == FacesConfigPackage.eINSTANCE - .getFacesConfigType_Lifecycle()) { - resetLifecycleInput(); - } - } - } - } - - public void addSelectionChangedListener(ISelectionChangedListener listener) { - // TODO Auto-generated method stub - - selectionChangedListeners.add(listener); - } - - public ISelection getSelection() { - if (currentSelection != null) - return currentSelection; - - return StructuredSelection.EMPTY; - } - - public void removeSelectionChangedListener( - ISelectionChangedListener listener) { - // TODO Auto-generated method stub - - selectionChangedListeners.remove(listener); - } - - public void selectionChanged(SelectionChangedEvent event) { - currentSelection = event.getSelection(); - if (event.getSource() instanceof OthersPageBaseSection) { - OthersPageBaseSection source = (OthersPageBaseSection) event - .getSource(); - - if (source.getSection().isExpanded()) { - for (int i = 0, n = selectionChangedListeners.size(); i < n; i++) { - ((ISelectionChangedListener) selectionChangedListeners - .get(i)).selectionChanged(event); - } - } - } - } - - /** - * get the section that is expanded. - * - * @return the page section - */ - protected OthersPageBaseSection getActiveSection() { - for (int i = 0, n = leftSections.size(); i < n; i++) { - - OthersPageBaseSection section = (OthersPageBaseSection) leftSections - .get(i); - if (section.getSection().isExpanded()) { - return section; - } - } - - for (int i = 0, n = rightSections.size(); i < n; i++) { - - OthersPageBaseSection section = (OthersPageBaseSection) leftSections - .get(i); - if (section.getSection().isExpanded()) { - return section; - } - } - return null; - - } - - public Object getAdapter(Class adapter) { - - if (adapter == IPropertySheetPage.class) { - return getPropertySheetPage(); - } - - if (adapter == IContentOutlinePage.class) { - return getOutlinePage(); - } - - return super.getAdapter(adapter); - } - - private IPropertySheetPage getPropertySheetPage() { - - AdapterFactoryEditingDomain editingDomain = (AdapterFactoryEditingDomain) getEditor() - .getAdapter(EditingDomain.class); - AdapterFactory adapterFactory = (AdapterFactory) getEditor() - .getAdapter(AdapterFactory.class); - if (propertySheetPage == null) { - propertySheetPage = new ExtendedPropertySheetPage(editingDomain) { - public void setSelectionToViewer(List selection) { - // FacesConfigEditor.this.setSelectionToViewer(selection); - // FacesConfigEditor.this.setFocus(); - } - - public void setActionBars(IActionBars actionBars) { - super.setActionBars(actionBars); - // getActionBarContributor().shareGlobalActions(this, - // actionBars); - } - }; - ((ExtendedPropertySheetPage) propertySheetPage) - .setPropertySourceProvider(new AdapterFactoryContentProvider( - adapterFactory)); - // this.addSelectionChangedListener((ExtendedPropertySheetPage) - // propertySheetPage); - } - - return propertySheetPage; - - } - - private IContentOutlinePage getOutlinePage() { - - if (contentOutlinePage == null) { - // The content outline is just a tree. - // - class OthersContentOutlinePage extends ContentOutlinePage { - public void createControl(Composite parent) { - super.createControl(parent); - TreeViewer contentOutlineViewer = getTreeViewer(); - contentOutlineViewer.addSelectionChangedListener(this); - - AdapterFactory adapterFactory = (AdapterFactory) getEditor() - .getAdapter(AdapterFactory.class); - // Set up the tree viewer. - contentOutlineViewer - .setContentProvider(new AdapterFactoryContentProvider( - adapterFactory)); - contentOutlineViewer - .setLabelProvider(new AdapterFactoryLabelProvider( - adapterFactory)); - contentOutlineViewer.addFilter(new ViewerFilter() { - - public boolean select(Viewer viewer, - Object parentElement, Object element) { - return FacesConfigPackage.eINSTANCE - .getApplicationType().isInstance(element) - || FacesConfigPackage.eINSTANCE - .getFactoryType().isInstance( - element) - || FacesConfigPackage.eINSTANCE - .getLifecycleType().isInstance( - element) - || FacesConfigPackage.eINSTANCE - .getActionListenerType() - .isInstance(element) - || FacesConfigPackage.eINSTANCE - .getDefaultRenderKitIdType() - .isInstance(element) - || FacesConfigPackage.eINSTANCE - .getLocaleConfigType().isInstance( - element) - || FacesConfigPackage.eINSTANCE - .getDefaultLocaleType().isInstance( - element) - || FacesConfigPackage.eINSTANCE - .getSupportedLocaleType() - .isInstance(element) - || FacesConfigPackage.eINSTANCE - .getMessageBundleType().isInstance( - element) - || FacesConfigPackage.eINSTANCE - .getNavigationHandlerType() - .isInstance(element) - || FacesConfigPackage.eINSTANCE - .getPropertyResolverType() - .isInstance(element) - || FacesConfigPackage.eINSTANCE - .getStateManagerType().isInstance( - element) - || FacesConfigPackage.eINSTANCE - .getVariableResolverType() - .isInstance(element) - || FacesConfigPackage.eINSTANCE - .getViewHandlerType().isInstance( - element) - || FacesConfigPackage.eINSTANCE - .getApplicationFactoryType() - .isInstance(element) - || FacesConfigPackage.eINSTANCE - .getFacesContextFactoryType() - .isInstance(element) - || FacesConfigPackage.eINSTANCE - .getLifecycleFactoryType() - .isInstance(element) - || FacesConfigPackage.eINSTANCE - .getRenderKitFactoryType() - .isInstance(element) - || FacesConfigPackage.eINSTANCE - .getPhaseListenerType().isInstance( - element) - - ; - } - }); - - contentOutlineViewer.setSorter(new ViewerSorter()); - contentOutlineViewer.setInput(getInput()); - } - - } - - contentOutlinePage = new OthersContentOutlinePage(); - - // Listen to selection so that we can handle it is a special - // way. - // - contentOutlinePage - .addSelectionChangedListener(new ISelectionChangedListener() { - // This ensures that we handle selections correctly. - public void selectionChanged(SelectionChangedEvent event) { - setSelection(event.getSelection()); - } - }); - - } - - return contentOutlinePage; - - } - - /** - * handle the selection changed event from outline page. - * - * @param selection - */ - public void setSelection(ISelection selection) { - - if (selection instanceof IStructuredSelection) { - IStructuredSelection ss = (IStructuredSelection) selection; - if (ss.isEmpty()) - return; - - EObject object = (EObject) ss.getFirstElement(); - OthersPageBaseSection section = null; - - if (FacesConfigPackage.eINSTANCE.getActionListenerType() - .isInstance(object)) { - section = (OthersPageBaseSection) leftSections.get(0); - } else if (FacesConfigPackage.eINSTANCE.getDefaultRenderKitIdType() - .isInstance(object)) { - section = (OthersPageBaseSection) leftSections.get(1); - } else if (FacesConfigPackage.eINSTANCE.getLocaleConfigType() - .isInstance(object)) { - section = (OthersPageBaseSection) leftSections.get(2); - } else if (FacesConfigPackage.eINSTANCE.getDefaultLocaleType() - .isInstance(object)) { - section = (OthersPageBaseSection) leftSections.get(2); - } else if (FacesConfigPackage.eINSTANCE.getSupportedLocaleType() - .isInstance(object)) { - section = (OthersPageBaseSection) leftSections.get(2); - } else if (FacesConfigPackage.eINSTANCE.getMessageBundleType() - .isInstance(object)) { - section = (OthersPageBaseSection) leftSections.get(3); - } else if (FacesConfigPackage.eINSTANCE.getNavigationHandlerType() - .isInstance(object)) { - section = (OthersPageBaseSection) leftSections.get(4); - } else if (FacesConfigPackage.eINSTANCE.getPropertyResolverType() - .isInstance(object)) { - section = (OthersPageBaseSection) leftSections.get(5); - } else if (FacesConfigPackage.eINSTANCE.getStateManagerType() - .isInstance(object)) { - section = (OthersPageBaseSection) leftSections.get(6); - } else if (FacesConfigPackage.eINSTANCE.getVariableResolverType() - .isInstance(object)) { - section = (OthersPageBaseSection) leftSections.get(7); - } else if (FacesConfigPackage.eINSTANCE.getViewHandlerType() - .isInstance(object)) { - section = (OthersPageBaseSection) leftSections.get(8); - } else if (FacesConfigPackage.eINSTANCE.getApplicationFactoryType() - .isInstance(object)) { - section = (OthersPageBaseSection) rightSections.get(0); - } else if (FacesConfigPackage.eINSTANCE - .getFacesContextFactoryType().isInstance(object)) { - section = (OthersPageBaseSection) rightSections.get(1); - } else if (FacesConfigPackage.eINSTANCE.getLifecycleFactoryType() - .isInstance(object)) { - section = (OthersPageBaseSection) rightSections.get(2); - } else if (FacesConfigPackage.eINSTANCE.getRenderKitFactoryType() - .isInstance(object)) { - section = (OthersPageBaseSection) rightSections.get(3); - } else if (FacesConfigPackage.eINSTANCE.getPhaseListenerType() - .isInstance(object)) { - section = (OthersPageBaseSection) rightSections.get(4); - } - if (section != null) { - if (!section.getSection().isExpanded()) { - this.closeOtherSections(section); - GridData gd = new GridData(GridData.FILL_BOTH); - section.getSection().setLayoutData(gd); - section.getSection().setExpanded(true); - } - IStructuredSelection newselection = new StructuredSelection( - object); - section.getTableViewer().setSelection(newselection); - } - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.emf.edit.domain.IEditingDomainProvider#getEditingDomain() - */ - public EditingDomain getEditingDomain() { - return ((FacesConfigEditor) getEditor()).getEditingDomain(); - } -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/OverviewPage.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/OverviewPage.java deleted file mode 100644 index adab23118..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/OverviewPage.java +++ /dev/null @@ -1,233 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.page; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigType; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.FacesConfigEditor; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.jst.jsf.facesconfig.ui.section.OverviewComponentsSection; -import org.eclipse.jst.jsf.facesconfig.ui.section.OverviewGeneralSection; -import org.eclipse.jst.jsf.facesconfig.ui.section.OverviewManagedBeanSection; -import org.eclipse.jst.jsf.facesconfig.ui.section.OverviewNavigationSection; -import org.eclipse.jst.jsf.facesconfig.ui.section.OverviewOthersSection; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.editor.FormEditor; -import org.eclipse.ui.forms.editor.FormPage; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.forms.widgets.ScrolledForm; - -/** - * @author jchoi, Xiao-guang Zhang - * @version - */ -public class OverviewPage extends FormPage implements ISelectionProvider, - IFacesConfigPage { - - private static final int LAYOUT_MARGIN_HEIGHT = 2; - - private static final int LAYOUT_MARGIN_WIDTH = 2; - - private Object input; - - private OverviewGeneralSection generalSection; - - private OverviewManagedBeanSection beanSection; - - private OverviewComponentsSection componentsSection; - - // - private OverviewNavigationSection navigationSection; - - // - private OverviewOthersSection otherSection; - - /** - * - * @param editor - */ - public OverviewPage(FormEditor editor) { - super(editor, "OverviewPage", EditorMessages.OverviewPage_page_name); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.forms.editor.FormPage#createFormContent(org.eclipse.ui.forms.IManagedForm) - */ - protected void createFormContent(IManagedForm managedForm) { - - ScrolledForm form = managedForm.getForm(); - form.setText(EditorMessages.OverviewPage_PageflowOverview_summary); - form.setBackgroundImage(EditorPlugin.getDefault().getImage( - "form_banner.gif")); //$NON-NLS-1$ - Composite body = form.getBody(); - GridLayout gridLayout = new GridLayout(); - gridLayout.marginWidth = LAYOUT_MARGIN_WIDTH; - gridLayout.marginHeight = LAYOUT_MARGIN_HEIGHT; - body.setLayout(gridLayout); - gridLayout = new GridLayout(2, true); - form.getBody().setLayout(gridLayout); - FormEditor editor = getEditor(); - FormToolkit toolkit = editor.getToolkit(); - - // add overview general information - generalSection = new OverviewGeneralSection(managedForm.getForm() - .getBody(), managedForm, this, toolkit); - generalSection.initialize(); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan = 2; - generalSection.getSection().setLayoutData(gd); - - // Navigation section - navigationSection = new OverviewNavigationSection(managedForm.getForm() - .getBody(), managedForm, this, toolkit); - navigationSection.initialize(); - gd = new GridData(GridData.FILL_BOTH); - navigationSection.getSection().setLayoutData(gd); - navigationSection.getSection().setExpanded(true); - - // ManagedBeans section - beanSection = new OverviewManagedBeanSection(managedForm.getForm() - .getBody(), managedForm, this, toolkit); - beanSection.initialize(); - gd = new GridData(GridData.FILL_BOTH); - beanSection.getSection().setLayoutData(gd); - beanSection.getSection().setExpanded(true); - - /* components section */ - componentsSection = new OverviewComponentsSection(managedForm.getForm() - .getBody(), managedForm, this, toolkit); - componentsSection.initialize(); - gd = new GridData(GridData.FILL_BOTH); - componentsSection.getSection().setLayoutData(gd); - componentsSection.getSection().setExpanded(true); - - /* other sections */ - otherSection = new OverviewOthersSection(managedForm.getForm() - .getBody(), managedForm, this, toolkit); - otherSection.initialize(); - gd = new GridData(GridData.FILL_BOTH); - otherSection.getSection().setLayoutData(gd); - otherSection.getSection().setExpanded(true); - - this.getSite().setSelectionProvider(this); - - } - - /** - * set input for this page when the it got activated at the first time; if - * it's not the first time, then refresh the page. - * - * @see org.eclipse.ui.forms.editor.FormPage#setActive(boolean) - */ - public void setActive(boolean active) { - super.setActive(active); - if (active) { - if (getInput() != ((FacesConfigEditor) getEditor()) - .getFacesConfig()) { - setInput(((FacesConfigEditor) getEditor()).getFacesConfig()); - } else { - this.refresh(); - } - } - } - - /** - * - */ - public void setInput(Object input) { - if (input instanceof FacesConfigType) { - this.input = input; - navigationSection.setInput(input); - beanSection.setInput(input); - componentsSection.setInput(input); - otherSection.setInput(input); - } - } - - /** - * Call refreshAll on all sections on this page - */ - public void refreshAll() { - generalSection.refreshAll(); - navigationSection.refreshAll(); - beanSection.refreshAll(); - componentsSection.refreshAll(); - otherSection.refreshAll(); - } - - public Object getInput() { - return input; - } - - public void refresh() { - generalSection.refresh(); - navigationSection.refresh(); - beanSection.refresh(); - componentsSection.refresh(); - otherSection.refresh(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.forms.editor.IFormPage#isEditor() - */ - public boolean isEditor() { - return true; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ISelectionProvider#addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) - */ - public void addSelectionChangedListener(ISelectionChangedListener listener) { - // do not support change in selection - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection() - */ - public ISelection getSelection() { - return StructuredSelection.EMPTY; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ISelectionProvider#removeSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) - */ - public void removeSelectionChangedListener( - ISelectionChangedListener listener) { - // do not support change in selection - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection) - */ - public void setSelection(ISelection selection) { - // do not support change in selection - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/WaitForLoadPage.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/WaitForLoadPage.java deleted file mode 100644 index 1b201600f..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/WaitForLoadPage.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.page; - -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.editor.FormEditor; -import org.eclipse.ui.forms.editor.FormPage; -import org.eclipse.ui.forms.widgets.ScrolledForm; - -/** - * A page the exists only be used before the editor's model is fully loaded - * as a status placeholder while the user waits. - * - * @author cbateman - * - */ -public class WaitForLoadPage extends FormPage -{ - - /** - * @param editor the parent - * @param id the id of the editor within its parent - * @param title the title displayed to the user on the editor's tab - */ - public WaitForLoadPage(FormEditor editor, String id, String title) { - super(editor, id, title); - } - - @Override - protected void createFormContent(IManagedForm managedForm) { - // get the form - ScrolledForm form = managedForm.getForm(); - //FormToolkit toolkit = getEditor().getToolkit(); - form.setText(EditorMessages.FacesConfigEditor_WaitForLoadPage_Title); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/detail/ComponentDetailsPage.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/detail/ComponentDetailsPage.java deleted file mode 100644 index 9a882d542..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/detail/ComponentDetailsPage.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.page.detail; - -import org.eclipse.jst.jsf.facesconfig.ui.page.FacesConfigMasterDetailPage; -import org.eclipse.jst.jsf.facesconfig.ui.section.AttributeSection; -import org.eclipse.jst.jsf.facesconfig.ui.section.ComponentGeneralSection; -import org.eclipse.jst.jsf.facesconfig.ui.section.FacetSection; -import org.eclipse.jst.jsf.facesconfig.ui.section.IFacesConfigSection; -import org.eclipse.jst.jsf.facesconfig.ui.section.PropertySection; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * - * @author sfshi - * - */ -public class ComponentDetailsPage extends FacesConfigDetailsPage { - - /** - * - * @param page - */ - public ComponentDetailsPage(FacesConfigMasterDetailPage page) { - super(page); - } - - /** - * create the detail sections and set layout for them. - */ - protected IFacesConfigSection[] createDetailSections(Composite composite, - IManagedForm managedForm, FormToolkit toolkit, FacesConfigMasterDetailPage page) { - ComponentGeneralSection generalSection = new ComponentGeneralSection( - composite, managedForm, getPage(), toolkit); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - generalSection.getSection().setLayoutData(gd); - - AttributeSection attributeSection = new AttributeSection(composite, - managedForm, getPage(), toolkit); - gd = new GridData(GridData.FILL_HORIZONTAL); - attributeSection.getSection().setLayoutData(gd); - - FacetSection facetSection = new FacetSection(composite, managedForm, - getPage(), toolkit); - gd = new GridData(GridData.FILL_HORIZONTAL); - facetSection.getSection().setLayoutData(gd); - - PropertySection propertySection = new PropertySection(composite, - managedForm, getPage(), toolkit); - gd = new GridData(GridData.FILL_BOTH); - propertySection.getSection().setLayoutData(gd); - return new IFacesConfigSection[] { generalSection, attributeSection, facetSection, - propertySection }; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/detail/ConverterDetailsPage.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/detail/ConverterDetailsPage.java deleted file mode 100644 index 0e720f440..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/detail/ConverterDetailsPage.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.page.detail; - -import org.eclipse.jst.jsf.facesconfig.ui.page.FacesConfigMasterDetailPage; -import org.eclipse.jst.jsf.facesconfig.ui.section.AttributeSection; -import org.eclipse.jst.jsf.facesconfig.ui.section.ConverterGeneralSection; -import org.eclipse.jst.jsf.facesconfig.ui.section.IFacesConfigSection; -import org.eclipse.jst.jsf.facesconfig.ui.section.PropertySection; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * @author Bryan Yang - * - */ -public class ConverterDetailsPage extends FacesConfigDetailsPage { - - /** - * - * @param page - */ - public ConverterDetailsPage(FacesConfigMasterDetailPage page) { - super(page); - } - - /** - * create the detail sections and set layout for them. - */ - protected IFacesConfigSection[] createDetailSections(Composite composite, - IManagedForm managedForm, FormToolkit toolkit, FacesConfigMasterDetailPage page) { - ConverterGeneralSection generalSection = new ConverterGeneralSection( - composite, managedForm, getPage(), toolkit); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - generalSection.getSection().setLayoutData(gd); - - AttributeSection attributeSection = new AttributeSection(composite, - managedForm, getPage(), toolkit); - gd = new GridData(GridData.FILL_HORIZONTAL); - attributeSection.getSection().setLayoutData(gd); - - - PropertySection propertySection = new PropertySection(composite, - managedForm, getPage(), toolkit); - gd = new GridData(GridData.FILL_BOTH); - propertySection.getSection().setLayoutData(gd); - return new IFacesConfigSection[] { generalSection, attributeSection, - propertySection }; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/detail/FacesConfigDetailsPage.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/detail/FacesConfigDetailsPage.java deleted file mode 100644 index eec368ac5..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/detail/FacesConfigDetailsPage.java +++ /dev/null @@ -1,185 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.page.detail; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jst.jsf.facesconfig.ui.page.FacesConfigMasterDetailPage; -import org.eclipse.jst.jsf.facesconfig.ui.section.IFacesConfigSection; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.forms.AbstractFormPart; -import org.eclipse.ui.forms.IDetailsPage; -import org.eclipse.ui.forms.IFormPart; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * The detail part of a page. It contains several IFacesConfigSection instances. - * - * @author sfshi - * - */ -public abstract class FacesConfigDetailsPage extends AbstractFormPart implements - IDetailsPage, ISelectionProvider, ISelectionChangedListener { - - private FacesConfigMasterDetailPage page; - - private IFacesConfigSection[] detailSections; - - private List selectionChangedListeners = new ArrayList(); - - /** - * @param page - */ - public FacesConfigDetailsPage(FacesConfigMasterDetailPage page) { - super(); - this.page = page; - } - - public void createContents(Composite parent) { - GridLayout layout = new GridLayout(); - layout.marginWidth = 0; - layout.marginHeight = 0; - parent.setLayout(layout); - - parent.setLayoutData(new GridData(GridData.FILL_BOTH)); - - FormToolkit toolkit = getManagedForm().getToolkit(); - Composite detailsContainer = toolkit.createComposite(parent); - toolkit.paintBordersFor(detailsContainer); - detailsContainer.setLayoutData(new GridData(GridData.FILL_BOTH)); - - GridLayout gl = new GridLayout(); - gl.verticalSpacing = 0; - gl.marginHeight = 0; - detailsContainer.setLayout(gl); - - detailSections = createDetailSections(detailsContainer, - getManagedForm(), toolkit, page); - if (detailSections != null) { - for (int i = 0, n = detailSections.length; i < n; i++) { - detailSections[i].initialize(); - if (detailSections[i] instanceof ISelectionProvider) { - ((ISelectionProvider) detailSections[i]) - .addSelectionChangedListener(this); - } - } - } - } - - /** - * create the sub detail sections and set layout data for them. - * - * @param composite - * @param managedForm - * @param toolkit - * @param page_ - * @return the detail sections - */ - abstract protected IFacesConfigSection[] createDetailSections( - Composite composite, IManagedForm managedForm, FormToolkit toolkit, - FacesConfigMasterDetailPage page_); - - /** - * - */ - public void selectionChanged(IFormPart part, ISelection selection) { - Object selectedItem = ((StructuredSelection) selection) - .getFirstElement(); - if (detailSections != null) { - for (int i = 0, n = detailSections.length; i < n; i++) { - IFacesConfigSection aSection = detailSections[i]; - aSection.setInput(selectedItem); - } - } - - } - - /** - * @return the master/detail page for this page - */ - public FacesConfigMasterDetailPage getPage() { - return page; - } - - public void refresh() { - super.refresh(); - if (detailSections != null) { - for (int i = 0, n = detailSections.length; i < n; i++) { - detailSections[i].refresh(); - } - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) - */ - public void selectionChanged(SelectionChangedEvent event) { - for (Iterator listeners = selectionChangedListeners.iterator(); listeners - .hasNext();) { - ISelectionChangedListener listener = (ISelectionChangedListener) listeners - .next(); - listener.selectionChanged(new SelectionChangedEvent(this, event - .getSelection())); - } - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ISelectionProvider#addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) - */ - public void addSelectionChangedListener(ISelectionChangedListener listener) { - selectionChangedListeners.add(listener); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection() - */ - public ISelection getSelection() { - return StructuredSelection.EMPTY; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ISelectionProvider#removeSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) - */ - public void removeSelectionChangedListener( - ISelectionChangedListener listener) { - selectionChangedListeners.remove(listener); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection) - */ - public void setSelection(ISelection selection) { - // no selection allowed - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/detail/ManagedBeanDetailsPage.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/detail/ManagedBeanDetailsPage.java deleted file mode 100644 index 9ee1641c9..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/detail/ManagedBeanDetailsPage.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.page.detail; - -import org.eclipse.jst.jsf.facesconfig.ui.page.FacesConfigMasterDetailPage; -import org.eclipse.jst.jsf.facesconfig.ui.section.IFacesConfigSection; -import org.eclipse.jst.jsf.facesconfig.ui.section.InitializationSection; -import org.eclipse.jst.jsf.facesconfig.ui.section.ManagedBeanGeneralSection; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * - * @author sfshi - * - */ -public class ManagedBeanDetailsPage extends FacesConfigDetailsPage { - - /** - * - * @param page - */ - public ManagedBeanDetailsPage(FacesConfigMasterDetailPage page) { - super(page); - } - - /** - * create the detail sections and set layout for them. - */ - protected IFacesConfigSection[] createDetailSections(Composite composite, - IManagedForm managedForm, FormToolkit toolkit, FacesConfigMasterDetailPage page) { - ManagedBeanGeneralSection generalSection = new ManagedBeanGeneralSection( - composite, managedForm, getPage(), toolkit); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - generalSection.getSection().setLayoutData(gd); - - InitializationSection initializationSection = new InitializationSection( - composite, managedForm, getPage(), toolkit); - gd = new GridData(GridData.FILL_BOTH | GridData.VERTICAL_ALIGN_FILL); - initializationSection.getSection().setLayoutData(gd); - - return new IFacesConfigSection[] { generalSection, initializationSection}; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/detail/RenderkitDetailsPage.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/detail/RenderkitDetailsPage.java deleted file mode 100644 index efb8dd7a5..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/detail/RenderkitDetailsPage.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.page.detail; - -import org.eclipse.jst.jsf.facesconfig.ui.page.FacesConfigMasterDetailPage; -import org.eclipse.jst.jsf.facesconfig.ui.section.IFacesConfigSection; -import org.eclipse.jst.jsf.facesconfig.ui.section.RendererSection; -import org.eclipse.jst.jsf.facesconfig.ui.section.RenderkitGeneralSection; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * @author Bryan Yang - * - */ -public class RenderkitDetailsPage extends FacesConfigDetailsPage { - - /** - * - * @param page - */ - public RenderkitDetailsPage(FacesConfigMasterDetailPage page) { - super(page); - } - - /** - * create the detail sections and set layout for them. - */ - protected IFacesConfigSection[] createDetailSections(Composite composite, - IManagedForm managedForm, FormToolkit toolkit, FacesConfigMasterDetailPage page) { - RenderkitGeneralSection generalSection = new RenderkitGeneralSection( - composite, managedForm, getPage(), toolkit); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - generalSection.getSection().setLayoutData(gd); - - RendererSection rendererSection = new RendererSection(composite, - managedForm, getPage(), toolkit); - gd = new GridData(GridData.FILL_BOTH | GridData.VERTICAL_ALIGN_FILL); - rendererSection.getSection().setLayoutData(gd); - - return new IFacesConfigSection[] { generalSection,rendererSection }; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/detail/ValidatorDetailsPage.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/detail/ValidatorDetailsPage.java deleted file mode 100644 index a2385781a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/page/detail/ValidatorDetailsPage.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.page.detail; - -import org.eclipse.jst.jsf.facesconfig.ui.page.FacesConfigMasterDetailPage; -import org.eclipse.jst.jsf.facesconfig.ui.section.AttributeSection; -import org.eclipse.jst.jsf.facesconfig.ui.section.IFacesConfigSection; -import org.eclipse.jst.jsf.facesconfig.ui.section.PropertySection; -import org.eclipse.jst.jsf.facesconfig.ui.section.ValidatorGeneralSection; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * @author Bryan Yang - * - */ -public class ValidatorDetailsPage extends FacesConfigDetailsPage { - - /** - * - * @param page - */ - public ValidatorDetailsPage(FacesConfigMasterDetailPage page) { - super(page); - } - - /** - * create the detail sections and set layout for them. - */ - protected IFacesConfigSection[] createDetailSections(Composite composite, - IManagedForm managedForm, FormToolkit toolkit, FacesConfigMasterDetailPage page) { - ValidatorGeneralSection generalSection = new ValidatorGeneralSection( - composite, managedForm, getPage(), toolkit); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - generalSection.getSection().setLayoutData(gd); - - AttributeSection attributeSection = new AttributeSection(composite, - managedForm, getPage(), toolkit); - gd = new GridData(GridData.FILL_HORIZONTAL); - attributeSection.getSection().setLayoutData(gd); - - PropertySection propertySection = new PropertySection(composite, - managedForm, getPage(), toolkit); - gd = new GridData(GridData.FILL_BOTH); - propertySection.getSection().setLayoutData(gd); - return new IFacesConfigSection[] { generalSection, attributeSection, - propertySection }; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/DelegatingZoomManager.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/DelegatingZoomManager.java deleted file mode 100644 index 1bef22f38..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/DelegatingZoomManager.java +++ /dev/null @@ -1,374 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow; - -// import org.eclipse.core.runtime.ListenerList; -import org.eclipse.core.runtime.ListenerList; -import org.eclipse.draw2d.ScalableFigure; -import org.eclipse.draw2d.Viewport; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.editparts.ZoomListener; -import org.eclipse.gef.editparts.ZoomManager; - -/** - * A delegating ZoomManager. - * - */ -public class DelegatingZoomManager extends ZoomManager implements ZoomListener { - /** Default string or double value of zoom level */ - private static final String DEFAULT_ZOOM_LEVEL_STRING = "100%"; - - private static final double DEFAULT_ZOOM_LEVEL = 1; - - /** the current ZoomManager all work is delegated to */ - private ZoomManager currentZoomManager = null; - - /** listeners of zoom */ - private ListenerList zoomListeners = new ListenerList( - ListenerList.IDENTITY); - - /** - * Creates a new DelegatingZoomManager instance. - */ - public DelegatingZoomManager() { - super((ScalableFigure) null, (Viewport) null); - } - - /* - * (non-Javadoc) - * - * @see ZoomListener#zoomChanged(double) - */ - public void zoomChanged(double zoom) { - Object[] listeners = zoomListeners.getListeners(); - for (int i = 0; i < listeners.length; ++i) { - ((ZoomListener) listeners[i]).zoomChanged(zoom); - } - } - - /* - * (non-Javadoc) - * - * @see ZoomManager#addZoomListener(ZoomListener) - */ - public void addZoomListener(ZoomListener listener) { - zoomListeners.add(listener); - } - - /* - * (non-Javadoc) - * - * @see ZoomManager#removeZoomListener(oZoomListener) - */ - public void removeZoomListener(ZoomListener listener) { - zoomListeners.remove(listener); - } - - /** - * Sets the ZoomManager all work should be delegated to. - * - * @param zoomManager - */ - public void setCurrentZoomManager(ZoomManager zoomManager) { - if (null != currentZoomManager) { - currentZoomManager.removeZoomListener(this); - } - - currentZoomManager = zoomManager; - if (null != currentZoomManager) { - currentZoomManager.addZoomListener(this); - zoomChanged(currentZoomManager.getZoom()); - } - } - - /* - * (non-Javadoc) - * - * @see ZoomManager#canZoomIn() - */ - public boolean canZoomIn() { - if (null == currentZoomManager) { - return false; - } - - return currentZoomManager.canZoomIn(); - } - - /* - * (non-Javadoc) - * - * @see ZoomManager#canZoomOut() - */ - public boolean canZoomOut() { - if (null == currentZoomManager) { - return false; - } - - return currentZoomManager.canZoomOut(); - } - - /* - * (non-Javadoc) - * - * @see ZoomManager#getMaxZoom() - */ - public double getMaxZoom() { - if (null == currentZoomManager) { - return DEFAULT_ZOOM_LEVEL; - } - - return currentZoomManager.getMaxZoom(); - } - - /* - * (non-Javadoc) - * - * @see ZoomManager#getMinZoom() - */ - public double getMinZoom() { - if (null == currentZoomManager) { - return DEFAULT_ZOOM_LEVEL; - } - - return currentZoomManager.getMinZoom(); - } - - /* - * (non-Javadoc) - * - * @see ZoomManager#getNextZoomLevel() - */ - public double getNextZoomLevel() { - if (null == currentZoomManager) { - return DEFAULT_ZOOM_LEVEL; - } - - return currentZoomManager.getNextZoomLevel(); - } - - /* - * (non-Javadoc) - * - * @see ZoomManager#getPreviousZoomLevel() - */ - public double getPreviousZoomLevel() { - if (null == currentZoomManager) { - return DEFAULT_ZOOM_LEVEL; - } - - return currentZoomManager.getPreviousZoomLevel(); - } - - /* - * (non-Javadoc) - * - * @see ZoomManager#getScalableFigure() - */ - public ScalableFigure getScalableFigure() { - if (null == currentZoomManager) { - return null; - } - - return currentZoomManager.getScalableFigure(); - } - - /* - * (non-Javadoc) - * - * @see ZoomManager#getUIMultiplier() - */ - public double getUIMultiplier() { - if (null == currentZoomManager) { - return DEFAULT_ZOOM_LEVEL; - } - - return currentZoomManager.getUIMultiplier(); - } - - /* - * (non-Javadoc) - * - * @see ZoomManager#getViewport() - */ - public Viewport getViewport() { - if (null == currentZoomManager) { - return null; - } - - return currentZoomManager.getViewport(); - } - - /* - * (non-Javadoc) - * - * @see ZoomManager#getZoom() - */ - public double getZoom() { - if (null == currentZoomManager) { - return DEFAULT_ZOOM_LEVEL; - } - - return currentZoomManager.getZoom(); - } - - /* - * (non-Javadoc) - * - * @see ZoomManager#getZoomAsText() - */ - public String getZoomAsText() { - if (null == currentZoomManager) { - return DEFAULT_ZOOM_LEVEL_STRING; - } - - return currentZoomManager.getZoomAsText(); - } - - /* - * (non-Javadoc) - * - * @see ZoomManager#getZoomLevels() - */ - public double[] getZoomLevels() { - if (null == currentZoomManager) { - return new double[] { DEFAULT_ZOOM_LEVEL }; - } - - return currentZoomManager.getZoomLevels(); - } - - /* - * (non-Javadoc) - * - * @see ZoomManager#getZoomLevelsAsText() - */ - public String[] getZoomLevelsAsText() { - if (null == currentZoomManager) { - return new String[] { DEFAULT_ZOOM_LEVEL_STRING }; - } - - return currentZoomManager.getZoomLevelsAsText(); - } - - /* - * (non-Javadoc) - * - * @see ZoomManager#setUIMultiplier(double) - */ - public void setUIMultiplier(double multiplier) { - if (null == currentZoomManager) { - return; - } - - currentZoomManager.setUIMultiplier(multiplier); - } - - /* - * (non-Javadoc) - * - * @see ZoomManager#setViewLocation(Point) - */ - public void setViewLocation(Point p) { - if (null == currentZoomManager) { - return; - } - - currentZoomManager.setViewLocation(p); - } - - /* - * (non-Javadoc) - * - * @see ZoomManager#setZoom(double) - */ - public void setZoom(double zoom) { - if (null == currentZoomManager) { - return; - } - currentZoomManager.setZoom(zoom); - } - - /* - * (non-Javadoc) - * - * @see ZoomManager#setZoomAnimationStyle(int) - */ - public void setZoomAnimationStyle(int style) { - if (null == currentZoomManager) { - return; - } - currentZoomManager.setZoomAnimationStyle(style); - } - - /* - * (non-Javadoc) - * - * @see ZoomManager#setZoomAsText(String) - */ - public void setZoomAsText(String zoomString) { - if (null == currentZoomManager) { - return; - } - currentZoomManager.setZoomAsText(zoomString); - } - - /* - * (non-Javadoc) - * - * @see ZoomManager#setZoomLevels(double[]) - */ - public void setZoomLevels(double[] zoomLevels) { - if (null == currentZoomManager) { - return; - } - currentZoomManager.setZoomLevels(zoomLevels); - } - - /* - * (non-Javadoc) - * - * @see ZoomManager#zoomIn() - */ - public void zoomIn() { - if (null == currentZoomManager) { - return; - } - currentZoomManager.zoomIn(); - } - - /* - * (non-Javadoc) - * - * @see ZoomManager#zoomOut() - */ - public void zoomOut() { - if (null == currentZoomManager) { - return; - } - currentZoomManager.zoomOut(); - } - - /* - * (non-Javadoc) - * - * @see ZoomManager#zoomTo(Rectangle) - */ - public void zoomTo(Rectangle rect) { - if (null == currentZoomManager) { - return; - } - currentZoomManager.zoomTo(rect); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowActionBarContributor.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowActionBarContributor.java deleted file mode 100644 index 9f9a081af..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowActionBarContributor.java +++ /dev/null @@ -1,122 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow; - -import org.eclipse.draw2d.PositionConstants; -import org.eclipse.gef.editparts.ZoomManager; -import org.eclipse.gef.ui.actions.ActionBarContributor; -import org.eclipse.gef.ui.actions.AlignmentRetargetAction; -import org.eclipse.gef.ui.actions.DeleteRetargetAction; -import org.eclipse.gef.ui.actions.GEFActionConstants; -import org.eclipse.gef.ui.actions.RedoRetargetAction; -import org.eclipse.gef.ui.actions.UndoRetargetAction; -import org.eclipse.gef.ui.actions.ZoomComboContributionItem; -import org.eclipse.gef.ui.actions.ZoomInRetargetAction; -import org.eclipse.gef.ui.actions.ZoomOutRetargetAction; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jst.jsf.facesconfig.ui.INestedActionContributor; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchActionConstants; -import org.eclipse.ui.actions.ActionFactory; - -public class PageflowActionBarContributor extends ActionBarContributor - implements INestedActionContributor { - - IEditorPart activeEditor; - - /* - * (non-Javadoc) - * - * @see ActionBarContributor#buildActions() - */ - protected void buildActions() { - addRetargetAction(new UndoRetargetAction()); - addRetargetAction(new RedoRetargetAction()); - addRetargetAction(new DeleteRetargetAction()); - addRetargetAction(new ZoomInRetargetAction()); - addRetargetAction(new ZoomOutRetargetAction()); - - addRetargetAction(new AlignmentRetargetAction(PositionConstants.LEFT)); - addRetargetAction(new AlignmentRetargetAction(PositionConstants.CENTER)); - addRetargetAction(new AlignmentRetargetAction(PositionConstants.RIGHT)); - addRetargetAction(new AlignmentRetargetAction(PositionConstants.TOP)); - addRetargetAction(new AlignmentRetargetAction(PositionConstants.MIDDLE)); - addRetargetAction(new AlignmentRetargetAction(PositionConstants.BOTTOM)); - } - - /* - * (non-Javadoc) - * - * @see ActionBarContributor#declareGlobalActionKeys() - */ - public void declareGlobalActionKeys() { - // do nothing - } - - public void updateActionKeys() { - declareGlobalActionKeys(); - } - - /* - * (non-Javadoc) - * - * @see EditorActionBarContributor#contributeToToolBar(IToolBarManager) - */ - public void contributeToToolBar(IToolBarManager tbm) { - tbm.add(getAction(ActionFactory.UNDO.getId())); - tbm.add(getAction(ActionFactory.REDO.getId())); - tbm.add(new Separator()); - tbm.add(getAction(GEFActionConstants.ALIGN_LEFT)); - tbm.add(getAction(GEFActionConstants.ALIGN_CENTER)); - tbm.add(getAction(GEFActionConstants.ALIGN_RIGHT)); - tbm.add(new Separator()); - tbm.add(getAction(GEFActionConstants.ALIGN_TOP)); - tbm.add(getAction(GEFActionConstants.ALIGN_MIDDLE)); - tbm.add(getAction(GEFActionConstants.ALIGN_BOTTOM)); - - tbm.add(new Separator()); - String[] zoomStrings = new String[] { ZoomManager.FIT_ALL, - ZoomManager.FIT_HEIGHT, ZoomManager.FIT_WIDTH }; - tbm.add(new ZoomComboContributionItem(getPage(), zoomStrings)); - } - - /* - * (non-Javadoc) - * - * @see EditorActionBarContributor#contributeToMenu(IMenuManager) - */ - public void contributeToMenu(IMenuManager menubar) { - super.contributeToMenu(menubar); - MenuManager viewMenu = new MenuManager("View"); - viewMenu.add(getAction(GEFActionConstants.ZOOM_IN)); - viewMenu.add(getAction(GEFActionConstants.ZOOM_OUT)); - menubar.insertAfter(IWorkbenchActionConstants.M_EDIT, viewMenu); - } - - public void setActiveEditor(IEditorPart editor) { - if (editor instanceof PageflowEditor) { - activeEditor = editor; - // updateActionKeys(); - super.setActiveEditor(editor); - } - } - - public void update() { - if (activeEditor != null) { - ((PageflowEditor) activeEditor).updateActions(); - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowEditor.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowEditor.java deleted file mode 100644 index 1efb7434e..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowEditor.java +++ /dev/null @@ -1,1216 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.IResourceDeltaVisitor; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.draw2d.PositionConstants; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.gef.ContextMenuProvider; -import org.eclipse.gef.DefaultEditDomain; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPartViewer; -import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.gef.GraphicalViewer; -import org.eclipse.gef.KeyHandler; -import org.eclipse.gef.KeyStroke; -import org.eclipse.gef.RootEditPart; -import org.eclipse.gef.commands.CommandStack; -import org.eclipse.gef.commands.CommandStackEvent; -import org.eclipse.gef.commands.CommandStackEventListener; -import org.eclipse.gef.editparts.ScalableFreeformRootEditPart; -import org.eclipse.gef.editparts.ScalableRootEditPart; -import org.eclipse.gef.editparts.ZoomManager; -import org.eclipse.gef.palette.PaletteRoot; -import org.eclipse.gef.requests.CreationFactory; -import org.eclipse.gef.ui.actions.ActionRegistry; -import org.eclipse.gef.ui.actions.DeleteAction; -import org.eclipse.gef.ui.actions.GEFActionConstants; -import org.eclipse.gef.ui.actions.RedoAction; -import org.eclipse.gef.ui.actions.SelectionAction; -import org.eclipse.gef.ui.actions.StackAction; -import org.eclipse.gef.ui.actions.UndoAction; -import org.eclipse.gef.ui.actions.UpdateAction; -import org.eclipse.gef.ui.actions.ZoomInAction; -import org.eclipse.gef.ui.actions.ZoomOutAction; -import org.eclipse.gef.ui.parts.GraphicalEditorWithFlyoutPalette; -import org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler; -import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer; -import org.eclipse.gef.ui.parts.SelectionSynchronizer; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.PreferenceConverter; -import org.eclipse.jface.resource.FontRegistry; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.util.TransferDropTargetListener; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jst.jsf.common.ui.internal.logging.Logger; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.action.AlignmentAction; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.action.OpenEditorAction; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.action.ShowPropertyViewAction; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.PreExecuteCommandStack; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.ConfigurableRootEditPart; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.IConnectionPreference; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.IFigurePreference; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.ILayerPanePreference; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.INodePreference; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowEditPartsFactory; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowNodeEditPart; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.synchronization.FC2PFTransformer; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.util.EditPartMarkerUtil; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.util.PageflowAnnotationUtil; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.util.PageflowModelManager; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.util.PageflowResourceFactory; -import org.eclipse.jst.jsf.facesconfig.ui.preference.GEMPreferences; -import org.eclipse.jst.jsf.facesconfig.ui.util.WebrootUtil; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorSite; -import org.eclipse.ui.ISelectionListener; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.actions.ActionFactory; -import org.eclipse.ui.ide.IGotoMarker; -import org.eclipse.ui.part.FileEditorInput; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.eclipse.ui.views.contentoutline.IContentOutlinePage; -import org.eclipse.ui.views.properties.IPropertySheetPage; -import org.eclipse.ui.views.properties.PropertySheetPage; - -/** - * This the the main editor page for modifying a complete pageflow. - */ -public class PageflowEditor extends GraphicalEditorWithFlyoutPalette implements - IAdaptable, IPropertyChangeListener, IGotoMarker { - /** log instance */ - private static final Logger log = EditorPlugin - .getLogger(PageflowEditor.class); - - /** pageflow context menu registration ID */ - private static final String PAGEFLOW_CONTEXTMENU_REG_ID = ".pageflow.editor.contextmenu"; - - /** the edit domain */ - private final DefaultEditDomain domain; - - /** the palette root */ - private PaletteRoot paletteRoot = null; - - /** the parent multi-page editor */ - private IEditorPart parentEditor = null; - - /** the graphical viewer */ - private GraphicalViewer viewer = null; - - /** the undoable <code>IPropertySheetPage</code> */ - private PropertySheetPage undoablePropertySheetPage = null; - - /** the editor's action registry */ - private ActionRegistry actionRegistry = null; - - public static final String PAGE_ID = "org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowEditor"; - - /** the list of action ids that are to EditPart actions */ - private List editPartActionIDs = new ArrayList(); - - /** the selection listener */ - private ISelectionListener selectionListener = new ISelectionListener() { - public void selectionChanged(IWorkbenchPart part, ISelection selection) { - updateActions(); - } - }; - - /** the selection synchronizer for the edit part viewer */ - private SelectionSynchronizer synchronizer = null; - - /** the shared key handler */ - private KeyHandler sharedKeyHandler = null; - - /** pageflow model manager */ - private PageflowModelManager pageflowManager; - - /** the dirty status of this page */ - private boolean isDirty = false; - - /** the command stack of this page */ - private CommandStack commandStack; - - private FC2PFTransformer modelsTransform; - - List stackActions = new ArrayList(); - - public FC2PFTransformer getModelsTransform() { - if (modelsTransform == null) { - modelsTransform = new FC2PFTransformer(); - } - return modelsTransform; - } - - public void updateActions() { - updateActions(stackActions); - updateActions(editPartActionIDs); - } - - /** - * This class listens for command stack changes of the page and decides if - * the editor is dirty or not. - * - */ - private class PageCommandStackListener implements CommandStackEventListener { - public void stackChanged(CommandStackEvent event) { - if (((CommandStack) event.getSource()).isDirty()) { - // at least one command stack is dirty, - // so the multi page editor is dirty too - setDirty(true); - } - updateActions(); - } - } - - /** - * This class listens to changes to the file system in the workspace, and - * validate the current pageflow based on web files' status. - */ - private class ResourceTracker implements IResourceChangeListener, - IResourceDeltaVisitor { - /* - * (non-Javadoc) - * - * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent) - */ - public void resourceChanged(IResourceChangeEvent event) { - IResourceDelta delta = event.getDelta(); - try { - if (delta != null) { - delta.accept(this); - } - } catch (CoreException exception) { - // Pageflow.PageflowEditor.Error.ResourceChange = Failed in the - // resource change. - log.error("Pageflow.PageflowEditor.Error.ResourceChange", - exception); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.resources.IResourceDeltaVisitor#visit(org.eclipse.core.resources.IResourceDelta) - */ - public boolean visit(IResourceDelta delta) { - // if the delta is not a file instance, just return true - if (!(delta.getResource() instanceof IFile)) { - return true; - } - - // web file is changed. - if (WebrootUtil.isValidWebFile(((IFile) delta.getResource()) - .getFullPath())) { - webPageChanged(((IFile) delta.getResource()).getFullPath()); - return false; - } - return false; - } - } - - /** the resource tracker instance */ - private ResourceTracker resourceTracker = null; - - /** - * Returns the resource tracker instance - * - * @return - Returns the resource tracker instance - */ - private ResourceTracker getResourceTracker() { - if (null == resourceTracker) { - resourceTracker = new ResourceTracker(); - } - return resourceTracker; - } - - /** - * Changes the dirty state. - * - * @param dirty - - * dirty state - */ - protected void setDirty(boolean dirty) { - if (isDirty != dirty) { - isDirty = dirty; - } - } - - /** - * Updates the specified actions. - * - * @param actionIds - - * the list of ids of actions to update - */ - protected void updateActions(List actionIds) { - for (Iterator ids = actionIds.iterator(); ids.hasNext();) { - IAction action = getActionRegistry().getAction(ids.next()); - if (null != action && action instanceof UpdateAction) { - ((UpdateAction) action).update(); - } - } - } - - /** - * Creates a new PageflowPage instance. - * <p> - * By design this page uses its own <code>EditDomain</code>. The main - * goal of this approach is that this page has its own undo/redo command - * stack. - * - * @param parent - - * the parent multi page editor - */ - public PageflowEditor(IEditorPart parent) { - domain = new DefaultEditDomain(parent); - domain.setCommandStack(getCommandStack()); - this.setEditDomain(domain); - parentEditor = parent; - } - - /** - * Adds an <code>CommandStack</code> action to this editor. - * <p> - * <code>CommandStack</code> actions are actions that depend and work on - * the <code>CommandStack</code>. - * - * @param action - - * the <code>CommandStack</code> action - */ - protected void addStackAction(StackAction action) { - getActionRegistry().registerAction(action); - stackActions.add(action.getId()); - } - - /** - * Creates different kinds of actions and registers them to the - * ActionRegistry. - */ - protected void createActions() { - // register delete action - addEditPartAction(new DeleteAction((IWorkbenchPart) this)); - // register undo/redo action - addStackAction(new UndoAction(this)); - addStackAction(new RedoAction(this)); - - // Allows opening of JSP files from the pageflow - addEditPartAction(new OpenEditorAction(this)); - - // Allows showing property view for the pageflow - SelectionAction action = new ShowPropertyViewAction(this); - action - .setImageDescriptor(getImageDescriptorForView("org.eclipse.ui.views.PropertySheet")); - addEditPartAction(action); - // Allows showing property view for the pageflow - // addEditPartAction(new ShowPaletteViewAction((IWorkbenchPart) this)); - - // register alignment actions - addEditPartAction(new AlignmentAction((IWorkbenchPart) this, - PositionConstants.LEFT)); - addEditPartAction(new AlignmentAction((IWorkbenchPart) this, - PositionConstants.RIGHT)); - addEditPartAction(new AlignmentAction((IWorkbenchPart) this, - PositionConstants.TOP)); - addEditPartAction(new AlignmentAction((IWorkbenchPart) this, - PositionConstants.BOTTOM)); - addEditPartAction(new AlignmentAction((IWorkbenchPart) this, - PositionConstants.CENTER)); - addEditPartAction(new AlignmentAction((IWorkbenchPart) this, - PositionConstants.MIDDLE)); - - // register zoom in/out action - IAction zoomIn = new ZoomInAction(getZoomManager(getGraphicalViewer())); - IAction zoomOut = new ZoomOutAction( - getZoomManager(getGraphicalViewer())); - addAction(zoomIn); - addAction(zoomOut); - - getSite().getKeyBindingService().registerAction(zoomIn); - getSite().getKeyBindingService().registerAction(zoomOut); - } - - /** - * Returns the zoom manager of the specified viewer. - * - * @param viewer_ - - * the viewer to get the zoom manager from - * @return - the zoom manager - */ - private ZoomManager getZoomManager(GraphicalViewer viewer_) { - // get zoom manager from root edit part - RootEditPart rootEditPart = viewer_.getRootEditPart(); - ZoomManager zoomManager = null; - if (rootEditPart instanceof ScalableFreeformRootEditPart) { - zoomManager = ((ScalableFreeformRootEditPart) rootEditPart) - .getZoomManager(); - } else if (rootEditPart instanceof ScalableRootEditPart) { - zoomManager = ((ScalableRootEditPart) rootEditPart) - .getZoomManager(); - } - return zoomManager; - } - - /** - * Adds an action to this editor's <code>ActionRegistry</code>. - * - * @param action - - * the action to add. - */ - protected void addAction(IAction action) { - getActionRegistry().registerAction(action); - } - - /** - * Adds an <code>EditPart</code> action to this editor. - * <p> - * <code>EditPart</code> actions are actions that depend and work on the - * selected <code>EditPart</code>s. - * - * @param action - - * the <code>EditPart</code> action - */ - protected void addEditPartAction(SelectionAction action) { - getActionRegistry().registerAction(action); - editPartActionIDs.add(action.getId()); - } - - /** - * Returns the action registry of this editor. - * - * @return - the action registry - */ - public ActionRegistry getActionRegistry() { - if (null == actionRegistry) { - actionRegistry = new ActionRegistry(); - } - - return actionRegistry; - } - - /** - * Creates the GraphicalViewer on the specified <code>Composite</code>. - * - * @param parent - - * the parent composite - */ - public void createGraphicalViewer(Composite parent) { - viewer = new ScrollingGraphicalViewer(); - viewer.createControl(parent); - - // configure the viewer - viewer.getControl().setBackground(parent.getBackground()); - - viewer.setRootEditPart(new ConfigurableRootEditPart()); - // _viewer.setRootEditPart(new ScalableFreeformRootEditPart()); - viewer.setKeyHandler(new GraphicalViewerKeyHandler(viewer)); - - // hook the viewer into the editor - registerEditPartViewer(viewer); - - // configure the viewer with context menu and template drag and drop - configureEditPartViewer(viewer); - - // initialize the viewer with input - viewer.setEditPartFactory(new PageflowEditPartsFactory()); - // viewer.setContents(getPageflow()); - - // support the resource drag&drop - viewer - .addDropTargetListener((TransferDropTargetListener) new ResourceTransferDropTargetListener( - viewer, getParentEditor()) { - protected CreationFactory getFactory(Object obj) { - return getResourceFactory((IResource) obj); - } - }); - - // apply Editor's preferences - // propertyChange(null); - // add listener to Editor's preferences changing - EditorPlugin.getDefault().getPreferenceStore() - .addPropertyChangeListener(this); - } - - /* - * (non-Javadoc) - * - * @see FlowEditor#getResourceFactory(IResource, ICodeGenEditor) - */ - protected CreationFactory getResourceFactory(IResource resource) { - return new PageflowResourceFactory(resource); - } - - /* - * (non-Javadoc) - * - * @see ISaveablePart#doSave(org.eclipse.core.runtime.IProgressMonitor) - */ - public final void doSave(IProgressMonitor monitor) { - // our policy: delegate saving to the parent - getParentEditor().doSave(monitor); - } - - /* - * (non-Javadoc) - * - * @see ISaveablePart#doSaveAs() - */ - public final void doSaveAs() { - // our policy: delegate saving to the parent - getParentEditor().doSaveAs(); - } - - /** - * Saves the pageflow under the specified path. - * @param file - * - * @param progressMonitor - * @throws CoreException - */ - public void doSave(IFile file, IProgressMonitor progressMonitor) - throws CoreException { - if (((FileEditorInput) getEditorInput()).getFile() != file) { - // TODO: save to other page. - } - if (null == progressMonitor) { - progressMonitor = new NullProgressMonitor(); - } - // Pageflow.Label.Saving = Saving - progressMonitor.beginTask(PageflowMessages.Pageflow_Label_Saving + " " - + file.getFullPath(), 2); - - if (null == getPageflowManager()) { - // Pageflow.PageflowEditor.Alert.nullModelManager = No model manager - // found for saving the file. - EditorPlugin.getAlerts().throwCoreException( - "Pageflow.PageflowEditor.Alert.nullModelManager"); - } - - // save pageflow to file - try { - getPageflowManager().save(getPageflowFilePath(file)); - - progressMonitor.worked(1); - file.refreshLocal(IResource.DEPTH_ZERO, new SubProgressMonitor( - progressMonitor, 1)); - progressMonitor.done(); - setDirty(false); - } catch (FileNotFoundException e) { - // Pageflow.PageflowEditor.Alert.errorSaveFileInfo = The current - // pageflow model could not be saved. - EditorPlugin.getAlerts().throwCoreException(e); - } catch (IOException e) { - // Pageflow.PageflowEditor.Alert.errorSaveFileInfo = The current - // pageflow model could not be saved. - EditorPlugin.getAlerts().throwCoreException(e); - } - } - - /* - * (non-Javadoc) - * - * @see IEditorPart#init(org.eclipse.ui.IEditorSite, - * org.eclipse.ui.IEditorInput) - */ - public void init(IEditorSite site, IEditorInput input) - throws PartInitException { - setSite(site); - setInput(input); - IFile fileFacesConfig = null; - try { - fileFacesConfig = ((FileEditorInput) input).getFile(); - - // load and validate pageflow - if (null == createPageflow(getPageflowFilePath(fileFacesConfig))) { - // Pageflow.PageflowEditor.Error.invalidPageflowFile = The - // specified input is not a valid pageflow. - log.error("Pageflow.PageflowEditor.Error.invalidPageflowFile"); - throw new PartInitException( - EditorPlugin - .getResourceString("Pageflow.PageflowEditor.Error.invalidPageflowFile")); - } - - } catch (CoreException e) { - // Pageflow.PageflowEditor.Error.invalidPageflowFile = The specified - // input is not a valid pageflow. - log.error("Pageflow.PageflowEditor.Error.invalidPageflowFile", e); - throw new PartInitException(e.getStatus()); - } catch (IOException e) { - // Pageflow.PageflowEditor.Alert.errorSaveFileInfo = The current - // pageflow model could not be saved. - log.error("Pageflow.PageflowEditor.Alert.errorSaveFileInfo", e); - } - - // add selection change listener - getSite().getWorkbenchWindow().getSelectionService() - .addSelectionListener(getSelectionListener()); - - // Add resource change listener - fileFacesConfig.getWorkspace().addResourceChangeListener( - getResourceTracker()); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IWorkbenchPart#dispose() - */ - public void dispose() { - // remove selection change listener - getModelsTransform().dispose(); - getSite().getWorkbenchWindow().getSelectionService() - .removeSelectionListener(getSelectionListener()); - - // remove listener to Editor's preferences changing - EditorPlugin.getDefault().getPreferenceStore() - .removePropertyChangeListener(this); - - if (getEditorInput() != null) { - IFile file = (IFile) getEditorInput().getAdapter(IResource.class); - if (file != null) { - file.getWorkspace().removeResourceChangeListener( - getResourceTracker()); - } - } - super.dispose(); - } - - /** - * get the pageflow file path based on faces-config.xml file path - * - * @return - */ - private IPath getPageflowFilePath(IFile file) { - IPath pageflowFilePath; - pageflowFilePath = PageflowModelManager.makePageflowPath(file - .getFullPath()); - return pageflowFilePath; - } - - /** - * Returns the pageflow object from the specified file. - * - * @param file - - * the file resource - * @return -the pageflow object from the specified file - * @throws IOException - */ - private Pageflow createPageflow(IPath pathPageflow) throws CoreException, - IOException { - Pageflow pageflow = null; - - try { - getPageflowManager().load(pathPageflow); - } catch (Exception e) { - // Pageflow.PageflowEditor.Error.invalidPageflowFile = The specified - // input is not a valid pageflow. - // _log.error("Pageflow.PageflowEditor.Error.invalidPageflowFile", - // e); - getPageflowManager().createPageflow(pathPageflow); - } - IFile fileFacesConfig = ((FileEditorInput) getEditorInput()).getFile(); - // it should update related config file - if (!fileFacesConfig.getFullPath().toString().trim().equalsIgnoreCase( - getPageflowManager().getModel().getConfigfile())) { - getPageflowManager().getModel().setConfigfile( - fileFacesConfig.getFullPath().toString()); - getPageflowManager().save(pathPageflow); - } - pageflow = getPageflowManager().getModel(); - if (null == pageflow) { - // Pageflow.PageflowEditor.Error.invalidPageflowModel = The model in - // the pageflow file is not a valid pageflow model. - log.error("Pageflow.PageflowEditor.Error.invalidPageflowModel"); - EditorPlugin.getAlerts().throwCoreException( - "Pageflow.PageflowEditor.Error.invalidPageflowModel"); - } - return pageflow; - } - - /** get the pageflow manager for this page */ - public PageflowModelManager getPageflowManager() { - if (pageflowManager == null) { - pageflowManager = new PageflowModelManager(); - } - return pageflowManager; - } - - /* - * (non-Javadoc) - * - * @see ISaveablePart#isDirty() - */ - public final boolean isDirty() { - return isDirty; - } - - /** - * Returns the <code>CommandStack</code> of this editor page. - * - * @return - the <code>CommandStack</code> of this editor page - */ - public final CommandStack getCommandStack() { - if (commandStack == null) { - commandStack = new PreExecuteCommandStack(); - commandStack - .addCommandStackEventListener(new PageCommandStackListener()); - } - return commandStack; - } - - /** - * Returns the default <code>PaletteRoot</code> for this editor and all - * its pages. - * - * @return - the default <code>PaletteRoot</code> - */ - protected PaletteRoot getPaletteRoot() { - if (null == paletteRoot) { - // create root - paletteRoot = new PageflowPaletteRoot(); - } - return paletteRoot; - } - - /* - * (non-Javadoc) - * - * @see ISaveablePart#isSaveAsAllowed() - */ - public final boolean isSaveAsAllowed() { - // our policy: delegate saving to the parent - return getParentEditor().isSaveAsAllowed(); - } - - /* - * (non-Javadoc) - * - * @see IWorkbenchPart#setFocus() - */ - public void setFocus() { - getGraphicalViewer().getControl().setFocus(); - } - - /** - * Returns the multi page pageflow editor this editor page is contained in. - * - * @return - the parent multi page editor - */ - protected final IEditorPart getParentEditor() { - return parentEditor; - } - - /** - * Returns the edit domain this editor page uses. - * - * @return - the edit domain this editor page uses - */ - public final DefaultEditDomain getEditDomain() { - return domain; - } - - /** - * Hooks a <code>EditPartViewer</code> to the rest of the Editor. - * <p> - * By default, the viewer is added to the SelectionSynchronizer, which can - * be used to keep 2 or more EditPartViewers in sync. The viewer is also - * registered as the ISelectionProvider for the Editor's PartSite. - * - * @param viewer_ - - * the viewer to hook into the editor - */ - protected void registerEditPartViewer(EditPartViewer viewer_) { - // register viewer to edit domain - getEditDomain().addViewer(viewer_); - - // the multi page pageflow editor keeps track of synchronizing - getSelectionSynchronizer().addViewer(viewer_); - - // add viewer as selection provider - getSite().setSelectionProvider(viewer_); - } - - /** - * Configures the specified <code>EditPartViewer</code> including context - * menu, key handler, etc. - * - * @param viewer_ - - * the pageflow graphical viewer. - */ - protected void configureEditPartViewer(EditPartViewer viewer_) { - // configure the shared key handler - if (null != viewer_.getKeyHandler()) { - viewer_.getKeyHandler().setParent(getSharedKeyHandler()); - } - // create the ActionRegistry - createActions(); - - // append the parent editor's action registry. - ActionRegistry actionRegistry_ = (ActionRegistry) getParentEditor() - .getAdapter(ActionRegistry.class); - if (actionRegistry_ != null) { - for (Iterator iter = actionRegistry_.getActions(); iter.hasNext();) { - getActionRegistry().registerAction((IAction) iter.next()); - } - } - // configure and register the context menu - ContextMenuProvider provider = new PageflowEditorContextMenuProvider( - viewer_, getActionRegistry()); - viewer_.setContextMenu(provider); - getSite().registerContextMenu( - EditorPlugin.getPluginId() + PAGEFLOW_CONTEXTMENU_REG_ID, - provider, getSite().getSelectionProvider()); //$NON-NLS-1$ - - // enable viewer as drop target for template transfers - viewer_ - .addDropTargetListener((TransferDropTargetListener) new PageflowTemplateTransferDropTargetListener( - viewer_)); - - } - - /** - * Returns the pageflow that is edited. - * - * @return - the pageflow that is edited - */ - public Pageflow getPageflow() { - return getPageflowManager().getModel(); - } - - /* - * (non-Javadoc) - * - * @see AbstractEditorPage#getGraphicalViewerForZoomSupport() - */ - public GraphicalViewer getGraphicalViewer() { - return viewer; - } - - public void setGraphicalViewerContents(Object contents) { - viewer.setContents(contents); - propertyChange(null); - } - - /* - * (non-Javadoc) - * - * @see IAdaptable#getAdapter(Class) - */ - public Object getAdapter(Class type) { - if (type == IContentOutlinePage.class) { - return getOutlinePage(); - } else if (type == CommandStack.class) { - return getCommandStack(); - } else if (type == ActionRegistry.class) { - return getActionRegistry(); - } else if (type == IPropertySheetPage.class) { - return getPropertySheetPage(); - } else if (type == ZoomManager.class) { - return getZoomManager(getGraphicalViewer()); - } - return super.getAdapter(type); - } - - /** - * Returns the outline page for the outline view with lazy creation - * - * @return - the outline page - */ - protected PageflowEditorOutlinePage getOutlinePage() { - PageflowEditorOutlinePage outlinePage = new PageflowEditorOutlinePage( - this); - outlinePage.initialize(this); - return outlinePage; - } - - /** - * Returns the undoable <code>PropertySheetPage</code> for this editor. - * - * @return - the undoable <code>PropertySheetPage</code> - */ - protected IPropertySheetPage getPropertySheetPage() { - if (null == undoablePropertySheetPage) { - undoablePropertySheetPage = new PropertySheetPage(); - - /** set the property source for property sheet page */ - undoablePropertySheetPage - .setRootEntry(new org.eclipse.gef.ui.properties.UndoablePropertySheetEntry( - (CommandStack) getAdapter(CommandStack.class))); - - } - - return undoablePropertySheetPage; - } - - /** - * Returns the selection syncronizer object. The synchronizer can be used to - * sync the selection of 2 or more EditPartViewers. - * - * @return - the syncrhonizer - */ - protected SelectionSynchronizer getSelectionSynchronizer() { - if (null == synchronizer) { - synchronizer = new SelectionSynchronizer(); - } - return synchronizer; - } - - /** - * Returns the shared KeyHandler that should be used for all viewers. - * - * @return - the shared KeyHandler - */ - protected KeyHandler getSharedKeyHandler() { - if (null == sharedKeyHandler) { - sharedKeyHandler = new KeyHandler(); - - // configure common keys for all viewers - sharedKeyHandler - .put(KeyStroke.getPressed(SWT.DEL, 127, 0), - getActionRegistry().getAction( - ActionFactory.DELETE.getId())); - sharedKeyHandler.put(KeyStroke.getPressed(SWT.F2, 0), - getActionRegistry().getAction( - GEFActionConstants.DIRECT_EDIT)); - } - return sharedKeyHandler; - } - - /** - * Returns the selection listener. - * - * @return - the <code>ISelectionListener</code> - */ - protected ISelectionListener getSelectionListener() { - return selectionListener; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) - */ - public void propertyChange(PropertyChangeEvent event) { - String property = (event == null) ? null : event.getProperty(); - - propagateProperty(property, viewer.getRootEditPart()); - } - - /** - * propagate property change to children edit part - * - * @param property - - * property's string name - * @param part - - * parent edit part. - */ - private void propagateProperty(String property, EditPart part) { - processPropertyChange(property, part); - - if (part instanceof GraphicalEditPart) { - // get the connections edit part - Iterator iterConns = ((GraphicalEditPart) part) - .getSourceConnections().iterator(); - while (iterConns.hasNext()) { - EditPart child = (EditPart) iterConns.next(); - propagateProperty(property, child); - } - } - Iterator iter = part.getChildren().iterator(); - while (iter.hasNext()) { - EditPart child = (EditPart) iter.next(); - propagateProperty(property, child); - } - } - - /** - * process the property change FIXME: The property change should be category - * to improve the performance. - * - * @param property - - * property's string name - * @param part - */ - private void processPropertyChange(String property, EditPart part) { - IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore(); - - if (property != null - && property.equals(GEMPreferences.USE_SYSTEM_COLORS)) { - // reload all properties - it's easiest - property = null; - } - - if (property == null || GEMPreferences.SNAP_TO_GRID.equals(property)) { - boolean bSnapToGrid = store.getBoolean(GEMPreferences.SNAP_TO_GRID); - if (part instanceof ILayerPanePreference) { - ((ILayerPanePreference) part).setGridVisible(bSnapToGrid); - } - } - - if (property == null || GEMPreferences.GRID_WIDTH.equals(property) - || GEMPreferences.GRID_HEIGHT.equals(property)) { - Dimension gridSpacing = new Dimension(store - .getInt(GEMPreferences.GRID_WIDTH), store - .getInt(GEMPreferences.GRID_HEIGHT)); - if (part instanceof ILayerPanePreference) { - ((ILayerPanePreference) part).setGridSpacing(gridSpacing); - } - } - - if (property == null || GEMPreferences.GRID_COLOR.equals(property)) { - Color gridFgColor = GEMPreferences.getColor(store, - GEMPreferences.GRID_COLOR); - if (part instanceof ILayerPanePreference) { - ((ILayerPanePreference) part) - .setGridForegroundColor(gridFgColor); - } - } - - if (property == null || GEMPreferences.CANVAS_COLOR.equals(property)) { - Color containerBgColor = GEMPreferences.getColor(store, - GEMPreferences.CANVAS_COLOR); - if (part instanceof IFigurePreference) { - ((IFigurePreference) part).setBackgroundColor(containerBgColor); - } - } - - if (property == null || GEMPreferences.LINE_WIDTH.equals(property)) { - int linkLineWidth = store.getInt(GEMPreferences.LINE_WIDTH); - - if (part instanceof IConnectionPreference) { - ((IConnectionPreference) part).setLineWidth(linkLineWidth); - } - } - - if (property == null || GEMPreferences.LINE_COLOR.equals(property)) { - Color linkLineColor = GEMPreferences.getColor(store, - GEMPreferences.LINE_COLOR); - if (part instanceof IConnectionPreference) { - ((IConnectionPreference) part) - .setForegroundColor(linkLineColor); - } - } - - if (property == null - || GEMPreferences.SHOW_LINE_LABELS.equals(property)) { - boolean bLinkLabelVisible = store - .getBoolean(GEMPreferences.SHOW_LINE_LABELS); - if (part instanceof IConnectionPreference) { - ((IConnectionPreference) part) - .setLabelVisible(bLinkLabelVisible); - } - } - - if (property == null || GEMPreferences.LINE_LABEL_FONT.equals(property) - || GEMPreferences.LINE_LABEL_FONT_COLOR.equals(property)) { - Font linkLabelFont = getLinkLabelFont(); - Color linkLabelFgColor = GEMPreferences.getColor(store, - GEMPreferences.LINE_LABEL_FONT_COLOR); - if (part instanceof IConnectionPreference) { - ((IConnectionPreference) part).setFont(linkLabelFont); - ((IConnectionPreference) part) - .setLabelForegroundColor(linkLabelFgColor); - } - } - - if (property == null - || GEMPreferences.LINE_LABEL_COLOR.equals(property)) { - Color linkLabelBgColor = GEMPreferences.getColor(store, - GEMPreferences.LINE_LABEL_COLOR); - if (part instanceof IConnectionPreference) { - ((IConnectionPreference) part) - .setLabelBackgroundColor(linkLabelBgColor); - } - } - - if (property == null || GEMPreferences.LINE_ROUTING.equals(property)) { - String connectionStyle = store - .getString(GEMPreferences.LINE_ROUTING); - int style; - if (GEMPreferences.LINE_ROUTING_MANHATTAN.equals(connectionStyle)) { - style = ILayerPanePreference.LINE_ROUTING_MANHATTAN; - } else { - style = ILayerPanePreference.LINE_ROUTING_MANUAL; - } - - if (part instanceof ILayerPanePreference) { - ((ILayerPanePreference) part).setConnectionRouterStyle(style); - } else if (part instanceof IConnectionPreference) { - ((IConnectionPreference) part).setConnectionRouterStyle(style); - } - } - - if (property == null - || GEMPreferences.FIGURE_LABEL_FONT.equals(property) - || GEMPreferences.FIGURE_LABEL_FONT_COLOR.equals(property)) { - Font nodeLabelFont = getNodeLabelFont(); - Color nodeLabelFgColor = GEMPreferences.getColor(store, - GEMPreferences.FIGURE_LABEL_FONT_COLOR); - - if (part instanceof INodePreference) { - ((INodePreference) part).setFont(nodeLabelFont); - ((INodePreference) part).setForegroundColor(nodeLabelFgColor); - } - } - - if (property == null || GEMPreferences.LABEL_PLACEMENT.equals(property)) { - int placement = PositionConstants.SOUTH; - String nodeLabelPlacement = store - .getString(GEMPreferences.LABEL_PLACEMENT); - if (GEMPreferences.LABEL_PLACEMENT_TOP.equals(nodeLabelPlacement)) - placement = PositionConstants.NORTH; - else if (GEMPreferences.LABEL_PLACEMENT_BOTTOM - .equals(nodeLabelPlacement)) - placement = PositionConstants.SOUTH; - else if (GEMPreferences.LABEL_PLACEMENT_LEFT - .equals(nodeLabelPlacement)) - placement = PositionConstants.WEST; - else if (GEMPreferences.LABEL_PLACEMENT_RIGHT - .equals(nodeLabelPlacement)) - placement = PositionConstants.EAST; - if (part instanceof INodePreference) - ((INodePreference) part).setTextPlacement(placement); - } - } - - private Font getLinkLabelFont() { - FontRegistry registry = JFaceResources.getFontRegistry(); - IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore(); - FontData fontData = PreferenceConverter.getFontData(store, - GEMPreferences.LINE_LABEL_FONT); - if (!registry.get(fontData.toString()).equals(registry.defaultFont())) - return registry.get(fontData.toString()); - - registry.put(fontData.toString(), new FontData[] {fontData}); - return registry.get(fontData.toString()); - } - - private Font getNodeLabelFont() { - FontRegistry registry = JFaceResources.getFontRegistry(); - IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore(); - FontData fontData = PreferenceConverter.getFontData(store, - GEMPreferences.FIGURE_LABEL_FONT); - if (!registry.get(fontData.toString()).equals(registry.defaultFont())) - return registry.get(fontData.toString()); - - registry.put(fontData.toString(), new FontData[] {fontData}); - return registry.get(fontData.toString()); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.ide.IGotoMarker#gotoMarker(org.eclipse.core.resources.IMarker) - */ - public void gotoMarker(IMarker marker) { - // The LOCATION attribute in the marker should be the ID string - Object id = null; - try { - id = marker.getAttribute(IMarker.LOCATION); - } catch (CoreException e) { - // Pageflow.PageflowEditor.Error.invalidMarkerAttribute = Unable to - // get marker's attribute - log - .error( - "Pageflow.PageflowEditor.Error.invalidMarkerAttribute", - e); - } - if (id instanceof String) { - GraphicalEditPart part = EditPartMarkerUtil.findEditPart( - (GraphicalEditPart) getGraphicalViewer().getRootEditPart(), - (String) id); - if (part != null) { - getGraphicalViewer().reveal(part); - getGraphicalViewer().select(part); - return; - } - } - - } - - /** - * the related web page is changed in outside editor, the pageflow should be - * revalidated to update the validation icons - * - * @param fullPath - */ - public void webPageChanged(IPath fullPath) { - PageflowPage page = getPageflowManager().foundPage( - WebrootUtil.getWebPath(fullPath)); - - if (page != null && getGraphicalViewer() != null - && getGraphicalViewer().getRootEditPart() != null) { - GraphicalEditPart pagePart = EditPartMarkerUtil.findEditPart( - (GraphicalEditPart) getGraphicalViewer().getRootEditPart(), - page.getId()); - PageflowAnnotationUtil - .validatePage((PageflowNodeEditPart) pagePart); - } - } - - /** - * Get the image desriptor from the view's id. - * - * @param viewid - * @return - */ - private ImageDescriptor getImageDescriptorForView(String viewid) { - IConfigurationElement[] elements = Platform.getExtensionRegistry() - .getConfigurationElementsFor("org.eclipse.ui.views"); - for (int i = 0; i < elements.length; i++) { - String name = elements[i].getName(); - String id = elements[i].getAttribute("id"); - if ("view".equals(name) && viewid.equals(id)) { - String iconPath = elements[i].getAttribute("icon"); - if (iconPath != null) { - return AbstractUIPlugin.imageDescriptorFromPlugin( - elements[i].getDeclaringExtension().getContributor().getName(), - iconPath); - } - } - } - return null; - } -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowEditorContextMenuProvider.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowEditorContextMenuProvider.java deleted file mode 100644 index 3e239190d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowEditorContextMenuProvider.java +++ /dev/null @@ -1,242 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow; - -import org.eclipse.gef.ContextMenuProvider; -import org.eclipse.gef.EditPartViewer; -import org.eclipse.gef.ui.actions.ActionRegistry; -import org.eclipse.gef.ui.actions.GEFActionConstants; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jst.jsf.facesconfig.ui.FacesConfigEditor; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.action.ShowPropertyViewAction; -import org.eclipse.ui.actions.ActionFactory; - -/** - * This is the context menu provider for pageflow editor. - * - */ -public class PageflowEditorContextMenuProvider extends ContextMenuProvider { - /** the action registry */ - private final ActionRegistry actionRegistry; - - /** - * Creates a new PageflowEditorContextMenuProvider instance. - * - * @param viewer - - * the editor viewer - * @param actionRegistry - - * action registry of the editor - */ - public PageflowEditorContextMenuProvider(EditPartViewer viewer, - ActionRegistry actionRegistry) { - super(viewer); - - this.actionRegistry = actionRegistry; - } - - /* - * (non-Javadoc) - * - * @see ContextMenuProvider#buildContextMenu(IMenuManager) - */ - public void buildContextMenu(IMenuManager menuManager) { - // add GEF menu groups, such as undo, edit, save, etc. - GEFActionConstants.addStandardActionGroups(menuManager); - - // add typical undo/redo commands - appendActionToUndoGroup(menuManager, ActionFactory.UNDO.getId()); - appendActionToUndoGroup(menuManager, ActionFactory.REDO.getId()); - // add edit commands, including copy, paste, delete - appendActionToEditGroup(menuManager, ActionFactory.COPY.getId()); - appendActionToEditGroup(menuManager, ActionFactory.PASTE.getId()); - appendActionToEditGroup(menuManager, ActionFactory.DELETE.getId()); - // Add Open Editor Action - appendActionToEditGroup(menuManager, FacesConfigEditor.EDITOR_ID); - - // append the save submenu - appendActionToSaveGroup(menuManager, ActionFactory.SAVE.getId()); - - // append the alignment submenu, including top, bottom, middle, left, - // right and center. - appendAlignmentSubmenu(menuManager); - - appendShowViewSubmenu(menuManager); - - } - - /** - * Appends the alignment subment. - * - * @param menuManager - * manager of workbench - */ - private void appendShowViewSubmenu(IMenuManager menuManager) { - // Show View Actions - MenuManager submenu = new MenuManager( - PageflowMessages.Pageflow_Contextmenu_ShowView_Label); - - IAction action = getActionRegistry().getAction( - ShowPropertyViewAction.SHOW_PROPERTY_VIEW); - if (null != action && action.isEnabled()) { - submenu.add(action); - } - - // action = getActionRegistry().getAction( - // ShowPaletteViewAction.SHOW_PALETTE_VIEW); - // if (null != action && action.isEnabled()) { - // submenu.add(action); - // } - - if (!submenu.isEmpty()) { - menuManager.appendToGroup(GEFActionConstants.GROUP_REST, submenu); - } - } - - /** - * Appends the alignment subment. - * - * @param menuManager - * manager of workbench - */ - private void appendAlignmentSubmenu(IMenuManager menuManager) { - // Alignment Actions - MenuManager submenu = new MenuManager( - PageflowMessages.Pageflow_Contextmenu_Align_Label); - - IAction action = getActionRegistry().getAction( - GEFActionConstants.ALIGN_LEFT); - if (null != action && action.isEnabled()) { - submenu.add(action); - } - - action = getActionRegistry().getAction(GEFActionConstants.ALIGN_CENTER); - if (null != action && action.isEnabled()) { - submenu.add(action); - } - - action = getActionRegistry().getAction(GEFActionConstants.ALIGN_RIGHT); - if (null != action && action.isEnabled()) { - submenu.add(action); - } - - action = getActionRegistry().getAction(GEFActionConstants.ALIGN_TOP); - if (null != action && action.isEnabled()) { - submenu.add(action); - } - - action = getActionRegistry().getAction(GEFActionConstants.ALIGN_MIDDLE); - if (null != action && action.isEnabled()) { - submenu.add(action); - } - - action = getActionRegistry().getAction(GEFActionConstants.ALIGN_BOTTOM); - if (null != action && action.isEnabled()) { - submenu.add(action); - } - - if (!submenu.isEmpty()) { - menuManager.appendToGroup(GEFActionConstants.GROUP_EDIT, submenu); - } - } - - /** - * Returns the action registry. - * - * @return - the action registry - */ - protected ActionRegistry getActionRegistry() { - return actionRegistry; - } - - /** - * Appends the specified action to the specified menu group - * - * @param menu - - * menu manager - * @param actionId - - * action's ID - * @param menuGroup - - * menu group name - */ - // TODO: dead code -// private void appendActionToMenu(IMenuManager menu, String actionId, -// String menuGroup) { -// IAction action = getActionRegistry().getAction(actionId); -// if (null != action && action.isEnabled()) { -// menu.appendToGroup(menuGroup, action); -// } -// } - - /** - * Appends the specified action to the 'Undo' menu group - * - * @param menu - - * menu manager - * @param actionId - - * action's ID - */ - private void appendActionToUndoGroup(IMenuManager menu, String actionId) { - IAction action = getActionRegistry().getAction(actionId); - if (null != action && action.isEnabled()) { - menu.appendToGroup(GEFActionConstants.GROUP_UNDO, action); - } - } - - /** - * Appends the specified action to the 'edit' menu group - * - * @param menu - - * menu manager - * @param actionId - - * action's ID - */ - private void appendActionToEditGroup(IMenuManager menu, String actionId) { - IAction action = getActionRegistry().getAction(actionId); - if (null != action && action.isEnabled()) { - menu.appendToGroup(GEFActionConstants.GROUP_EDIT, action); - } - } - - /** - * Appends the specified action to the 'add' menu group - * - * @param menu - - * menu manager - * @param actionId - - * action's ID - */ - // TODO: dead code -// private void appendActionToAddGroup(IMenuManager menu, String actionId) { -// IAction action = getActionRegistry().getAction(actionId); -// if (null != action && action.isEnabled()) { -// menu.appendToGroup(GEFActionConstants.GROUP_ADD, action); -// } -// } - - /** - * Appends the specified action to the 'save' menu group - * - * @param menu - - * menu manager - * @param actionId - - * action's ID - */ - private void appendActionToSaveGroup(IMenuManager menu, String actionId) { - IAction action = getActionRegistry().getAction(actionId); - if (null != action && action.isEnabled()) { - menu.appendToGroup(GEFActionConstants.GROUP_SAVE, action); - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowEditorOutlinePage.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowEditorOutlinePage.java deleted file mode 100644 index 2f036ad0d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowEditorOutlinePage.java +++ /dev/null @@ -1,545 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.LightweightSystem; -import org.eclipse.draw2d.MarginBorder; -import org.eclipse.draw2d.Viewport; -import org.eclipse.draw2d.parts.ScrollableThumbnail; -import org.eclipse.gef.ContextMenuProvider; -import org.eclipse.gef.EditDomain; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPartListener; -import org.eclipse.gef.EditPartViewer; -import org.eclipse.gef.LayerConstants; -import org.eclipse.gef.RootEditPart; -import org.eclipse.gef.editparts.ScalableFreeformRootEditPart; -import org.eclipse.gef.editparts.ScalableRootEditPart; -import org.eclipse.gef.ui.parts.TreeViewer; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowTreePartFactory; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Canvas; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.part.EditorPart; -import org.eclipse.ui.part.Page; -import org.eclipse.ui.part.PageBook; -import org.eclipse.ui.views.contentoutline.IContentOutlinePage; - -/** - * This is an implementation of an outline page showing an overview figure and - * an tree outline of the main graphical viewer provided by the current active - * page of an multi page editor. - * - */ -public class PageflowEditorOutlinePage extends Page implements - IContentOutlinePage { - /** the pageflow editor */ - private final PageflowEditor editor; - - /** the outlineContent for the tree viewer */ - private PageflowElement outlineContent = null; - - /** the control of the overview */ - private Canvas overview = null; - - /** the root edit part (outlineContent for the thumbnail) */ - private RootEditPart overviewContent = null; - - /** the thumbnail */ - private ScrollableThumbnail thumbnail = null; - - /** the tree viewer */ - private TreeViewer treeViewer = null; - - /** the control of the tree view */ - private Control outline = null; - - /** the pagebook */ - private PageBook pageBook = null; - - /** action for showing the tree page */ - private IAction showOutlineAction = null; - - /** action for showing the overview page */ - private IAction showOverviewAction = null; - - /** the LightweightSystem */ - private LightweightSystem lws = null; - - /** the edit domain */ - private EditDomain editDomain = null; - - /** - * Creates a new PageflowEditorOutlinePage instance. - * - * @param editor - - * Pageflow Editor - */ - public PageflowEditorOutlinePage(EditorPart editor) { - super(); - this.editor = (PageflowEditor) editor; - } - - /* - * (non-Javadoc) - * - * @see ISelectionProvider#addSelectionChangedListener(ISelectionChangedListener) - */ - public void addSelectionChangedListener(ISelectionChangedListener listener) { - getTreeViewer().addSelectionChangedListener(listener); - } - - /* - * (non-Javadoc) - * - * @see IPage#createControl(Composite) - */ - public void createControl(Composite parent) { - // pagebook - pageBook = new PageBook(parent, SWT.NONE); - - // tree viewer control - outline = getTreeViewer().createControl(pageBook); - configureEditPartViewer(getTreeViewer()); - - // overview canvas - overview = new Canvas(pageBook, SWT.NONE); - lws = new LightweightSystem(overview); - - // create actions - IToolBarManager tbm = getSite().getActionBars().getToolBarManager(); - showOutlineAction = new Action() { - public void run() { - showPage(outline); - } - }; - showOutlineAction.setImageDescriptor(EditorPlugin.getDefault() - .getImageDescriptor("facesconfig/Pageflow_Outline.gif")); //$NON-NLS-1$ - tbm.add(showOutlineAction); - showOverviewAction = new Action() { - public void run() { - showPage(overview); - } - }; - showOverviewAction.setImageDescriptor(EditorPlugin.getDefault() - .getImageDescriptor("facesconfig/Pageflow_Outline_Overview.gif")); //$NON-NLS-1$ - tbm.add(showOverviewAction); - - // initialize outline page - initializeOutlineViewer(); - - // initialize overview - initializeOverview(); - - // initialize pagebook - showPage(outline); - } - - /** - * Configures the outline viewer - */ - private void initializeOutlineViewer() { - if (null != getEditDomain()) { - getEditDomain().addViewer(getTreeViewer()); - } - // getTreeViewer().setEditPartFactory(new PageflowTreePartFactory()); - - // synchronize selections - editor.getSelectionSynchronizer().addViewer(getTreeViewer()); - - // add content - getTreeViewer().setContents(getOutlineContent()); - } - - /** - * Shows the spcified page. - * - * @param id - - * control id of pagebook in outline page. it is can be _outline - * or _overview - */ - protected void showPage(Control id) { - if (id == outline) { - showOutlineAction.setChecked(true); - showOverviewAction.setChecked(false); - pageBook.showPage(outline); - if (thumbnail != null) { - thumbnail.setVisible(false); - } - } else if (id == overview) { - showOutlineAction.setChecked(false); - showOverviewAction.setChecked(true); - pageBook.showPage(overview); - if (thumbnail != null) { - thumbnail.setVisible(true); - } - } - } - - /** - * Returns the current edit domain. - * - * @return - the edit domain - */ - public EditDomain getEditDomain() { - return editDomain; - } - - /* - * (non-Javadoc) - * - * @see IPage#dispose() - */ - public void dispose() { - editor.getSelectionSynchronizer().removeViewer(getTreeViewer()); - - if (null != thumbnail) { - thumbnail.deactivate(); - } - - super.dispose(); - } - - /** - * initialize Overview. - * - */ - private void initializeOverview() { - // check if control was created - if (null == lws) { - return; - } - - // deactivate old thumbnail - if (null != thumbnail) { - thumbnail.deactivate(); - } - - // create empty thumbnail - thumbnail = new ScrollableThumbnail(); - thumbnail.setBorder(new MarginBorder(3)); - lws.setContents(thumbnail); - - // initialize thumbnail - if (null != getOverviewContent()) { - Viewport viewport = null; - IFigure source = null; - if (getOverviewContent() instanceof ScalableFreeformRootEditPart) { - viewport = (Viewport) ((ScalableFreeformRootEditPart) getOverviewContent()) - .getFigure(); - source = ((ScalableFreeformRootEditPart) getOverviewContent()) - .getLayer(LayerConstants.PRINTABLE_LAYERS); - } - if (getOverviewContent() instanceof ScalableRootEditPart) { - viewport = (Viewport) ((ScalableRootEditPart) getOverviewContent()) - .getFigure(); - source = ((ScalableRootEditPart) getOverviewContent()) - .getLayer(LayerConstants.PRINTABLE_LAYERS); - } - - if (null != viewport && null != source) { - thumbnail.setViewport(viewport); - thumbnail.setSource(source); - } - } - } - - /** - * Returns the outlineContent. - * - * @return - the outlineContent - */ - public PageflowElement getOutlineContent() { - return outlineContent; - } - - /* - * (non-Javadoc) - * - * @see IPage#getControl() - */ - public Control getControl() { - return pageBook; - } - - /** - * Returns the root edit part - * - * @return - the root edit part - */ - public RootEditPart getOverviewContent() { - return overviewContent; - } - - /* - * (non-Javadoc) - * - * @see ISelectionProvider#getSelection() - */ - public ISelection getSelection() { - return getTreeViewer().getSelection(); - } - - /** - * Returns the tree viewer. - * - * @return - the tree viewer - */ - public TreeViewer getTreeViewer() { - if (null == treeViewer) { - treeViewer = new TreeViewer(); - treeViewer.setEditPartFactory(new PageflowTreePartFactory()); - } - - return treeViewer; - } - - /* - * (non-Javadoc) - * - * @see ISelectionProvider#removeSelectionChangedListener(ISelectionChangedListener) - */ - public void removeSelectionChangedListener( - ISelectionChangedListener listener) { - getTreeViewer().removeSelectionChangedListener(listener); - } - - /** - * Sets the outlineContent. - * - * @param element - - * Pageflow Element - */ - public void setOutlineContent(PageflowElement element) { - if (outlineContent != element) { - outlineContent = element; - - // refresh viewer - if (null != getTreeViewer().getControl()) { - getTreeViewer().setContents(element); - - // bugfix: something is overwriting visibility - if (null != pageBook) { - if (showOverviewAction.isChecked()) { - showPage(outline); - showPage(overview); - } else { - showPage(outline); - } - } - } - } - } - - /* - * (non-Javadoc) - * - * @see IPage#setFocus() - */ - public void setFocus() { - if (getControl() != null) { - getControl().setFocus(); - } - } - - /** - * Sets the root edit part. - * - * @param part - - * root edit part for pageflow model - */ - public void setOverviewContent(RootEditPart part) { - if (overviewContent != part) { - overviewContent = part; - // reinitialize thumbnail - // if (null != thumbnail && thumbnail.isVisible()) - initializeOverview(); - } - } - - /* - * (non-Javadoc) - * - * @see ISelectionProvider#setSelection(ISelection) - */ - public void setSelection(ISelection selection) { - getTreeViewer().setSelection(selection); - } - - /** - * Initializes this outline page from a given editor page. - * - * @param newPage - - * Pageflow EditorPage - */ - public void initialize(PageflowEditor newPage) { - if (null != newPage.getGraphicalViewer()) { - setOverviewContent(newPage.getGraphicalViewer().getRootEditPart()); - EditPart currentContent = newPage.getGraphicalViewer() - .getContents(); - setOutlineContent(null != currentContent ? (PageflowElement) currentContent - .getModel() - : null); - setEditDomain(newPage.getEditDomain()); - getViewerContentListener().setViewer(newPage.getGraphicalViewer()); - } else { - setOverviewContent(null); - setOutlineContent(null); - setEditDomain(null); - } - } - - /** - * Sets the edit domain. - * - * @param domain - - * editor's edit domain - */ - public void setEditDomain(EditDomain domain) { - if (editDomain != domain) { - // refresh viewer - if (null != getTreeViewer()) { - if (null != editDomain) { - editDomain.removeViewer(getTreeViewer()); - } - if (null != domain) { - domain.addViewer(getTreeViewer()); - } - } - editDomain = domain; - } - } - - /** - * the current viewer content listener - */ - private final ViewerContentListener viewerContentListener = new ViewerContentListener(); - - /** - * This class listens for changes of the content of an EditPartViewer. If - * the content changed, it will update the outline viewer. - * <p> - * Important: this class has to be disposed with - * <code>setViewer(null)</code>. - * - * @author Gunnar Wagenknecht - */ - private class ViewerContentListener implements EditPartListener { - /* the viewer */ - private EditPartViewer _viewer; - - /** - * Sets a new viewer. <code>null</code> is allowed to dispose. - * - * @param viewer - */ - public void setViewer(EditPartViewer viewer) { - if (null != this._viewer) - this._viewer.getRootEditPart().removeEditPartListener(this); - - this._viewer = viewer; - - if (null != this._viewer) - this._viewer.getRootEditPart().addEditPartListener(this); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.EditPartListener#childAdded(org.eclipse.gef.EditPart, - * int) - */ - public void childAdded(EditPart child, int index) { - // this is out event, update the viewers - if (child.getModel() instanceof PageflowElement) - setOutlineContent((PageflowElement) child.getModel()); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.EditPartListener#partActivated(org.eclipse.gef.EditPart) - */ - public void partActivated(EditPart editpart) { - // do nothing - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.EditPartListener#partDeactivated(org.eclipse.gef.EditPart) - */ - public void partDeactivated(EditPart editpart) { - // do nothing - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.EditPartListener#removingChild(org.eclipse.gef.EditPart, - * int) - */ - public void removingChild(EditPart child, int index) { - // do nothing - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.EditPartListener#selectedStateChanged(org.eclipse.gef.EditPart) - */ - public void selectedStateChanged(EditPart editpart) { - // do nothing - } - } - - /** - * Returns the viewer content listener. - * - * @return the viewer content listener - */ - private ViewerContentListener getViewerContentListener() { - return viewerContentListener; - } - - /** - * Configures the specified <code>EditPartViewer</code>. - * - * @param viewer - */ - protected void configureEditPartViewer(EditPartViewer viewer) { - // configure the shared key handler - if (viewer.getKeyHandler() != null) { - viewer.getKeyHandler().setParent(editor.getSharedKeyHandler()); - } - - // configure the context menu - ContextMenuProvider provider = new PageflowEditorContextMenuProvider( - viewer, editor.getActionRegistry()); - viewer.setContextMenu(provider); - getSite().registerContextMenu( - EditorPlugin.getPluginId() - + ".pageflow.editor.outlineview.contextmenu", provider, - getSite().getSelectionProvider()); //$NON-NLS-1$ - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowMessages.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowMessages.java deleted file mode 100644 index 64b31a60d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowMessages.java +++ /dev/null @@ -1,192 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow; - -import org.eclipse.osgi.util.NLS; - -public final class PageflowMessages extends NLS { - - private static final String BUNDLE_NAME = "org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowMessages"; - - private PageflowMessages() { - // Do not instantiate - } - - static { - NLS.initializeMessages(BUNDLE_NAME, PageflowMessages.class); - } - - public static String Pageflow_Label_True; - - public static String Pageflow_Label_False; - - public static String Pageflow_Label_Saving; - - public static String Pageflow_Dialog_Label_CreateFileTitle; - - public static String Pageflow_Dialog_Label_FileNotExistedPart1; - - public static String Pageflow_Dialog_Label_FileNotExistedPart2; - - public static String Pageflow_Action_OpenEditor_Label; - - public static String Pageflow_Action_OpenEditor_ToolTip; - - public static String Pageflow_Action_ShowPropertyView_Label; - - public static String Pageflow_Action_ShowPropertyView_ToolTip; - - public static String Pageflow_Action_ShowPaletteView_Label; - - public static String Pageflow_Action_ShowPaletteView_ToolTip; - - public static String Pageflow_Action_SyncWithFacesConfig_Label; - - public static String Pageflow_Action_SyncWithFacesConfig_ToolTip; - - public static String Pageflow_Action_UpdateFacesConfig_Label; - - public static String Pageflow_Action_UpdateFacesConfig_ToolTip; - - public static String Pageflow_PaletteTool_Group_Controls; - - public static String Pageflow_PaletteTool_Select_Label; - - public static String Pageflow_PaletteTool_Select_Description; - - public static String Pageflow_PaletteTool_Marquee_Label; - - public static String Pageflow_PaletteTool_Marquee_Description; - - public static String Pageflow_PaletteTool_Link_Label; - - public static String Pageflow_PaletteTool_Link_Description; - - public static String Pageflow_PaletteTool_Group_Nodes; - - public static String Pageflow_PaletteTool_Begin_Label; - - public static String Pageflow_PaletteTool_Begin_Description; - - public static String Pageflow_PaletteTool_End_Label; - - public static String Pageflow_PaletteTool_End_Description; - - public static String Pageflow_PaletteTool_Action_Label; - - public static String Pageflow_PaletteTool_Action_Description; - - public static String Pageflow_PaletteTool_Page_Label; - - public static String Pageflow_PaletteTool_Page_Description; - - public static String Pageflow_Contextmenu_Align_Label; - - public static String Pageflow_Contextmenu_ShowView_Label; - - public static String Pageflow_Commands_AddNodeCommand_Label; - - public static String Pageflow_Commands_CreateNodeCommand_Label; - - public static String Pageflow_Commands_DeleteNodeCommand_Label; - - public static String Pageflow_Commands_ConnectionCommand_Label; - - public static String Pageflow_Commands_CreateBendpointCommand_Label; - - public static String Pageflow_Commands_MoveBendpointCommand_Label; - - public static String Pageflow_Commands_DeleteBendpointCommand_Label; - - public static String Pageflow_Commands_OpenEditorCommand_Label; - - public static String Pageflow_Commands_OrphanChildCommand_Label; - - public static String Pageflow_Commands_UpdatePageflowCommand_Label; - - public static String Pageflow_Commands_CreateNodeCommand_SelectJSPDialog_Title; - - public static String Pageflow_Commands_CreateNodeCommand_SelectJSPDialog_Description; - - public static String Pageflow_Model_Attributes_comment; - - public static String Pageflow_Model_Attributes_name; - - public static String Pageflow_Model_Attributes_largeicon; - - public static String Pageflow_Model_Attributes_smallicon; - - public static String Pageflow_Model_Attributes_action; - - public static String Pageflow_Model_Attributes_path; - - public static String Pageflow_Model_Attributes_begin; - - public static String Pageflow_Model_Attributes_end; - - public static String Pageflow_Model_Attributes_configfile; - - public static String Pageflow_Model_Attributes_source; - - public static String Pageflow_Model_Attributes_target; - - public static String Pageflow_Model_Attributes_outcome; - - public static String Pageflow_Model_Attributes_redirect; - - public static String Pageflow_Model_Attributes_fromaction; - - public static String Pageflow_Model_Attributes_referenceLink; - - public static String Pageflow_Model_Items_Pageflow; - - public static String Pageflow_Model_Items_PFPage; - - public static String Pageflow_Model_Items_PFLink; - - public static String Pageflow_Property_Action_OutcomeSelectionDialog_Choice; - - public static String Pageflow_Property_Action_OutcomeSelectionDialog_Title; - - public static String Pageflow_Property_Action_OutcomeSelectionDialog_JSPName; - - public static String Pageflow_Property_Action_OutcomeSelectionDialog_ActionListTable_Title; - - public static String Pageflow_Property_Action_OutcomeSelectionDialog_ActionListTable_Component; - - public static String Pageflow_Property_Action_OutcomeSelectionDialog_ActionListTable_Action; - - public static String Pageflow_Property_Action_OutcomeSelectionDialog_Outcome; - - public static String Pageflow_Validation_UndefinedOutcome; - - public static String Pageflow_Validation_NotExistedSourcePage; - - public static String Pageflow_Validation_MissingSourcePage; - - public static String Pageflow_Validation_InvalidWebPage; - - public static String Pageflow_Validation_NotExitedWebPage; - - public static String Pageflow_Validation_MissingWebPage; - - public static String Pageflow_Validation_MissingManagedBean; - - public static String Pageflow_Validation_MissingAction; - - public static String ExistingPagePathDialogCellEdito_LabelText; - - public static String PageflowLinkEditPart_FromAction; - - public static String PageflowLinkEditPart_FromOutcome; -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowMessages.properties b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowMessages.properties deleted file mode 100644 index ece46896c..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowMessages.properties +++ /dev/null @@ -1,146 +0,0 @@ -############################################################################### -# Copyright (c) 2001, 2006 Oracle Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Oracle Corporation - initial API and implementation -############################################################################### -#################################################### -# Generic Strings for UI -#################################################### -Pageflow_Label_True=true -Pageflow_Label_False=false - -Pageflow_Label_Saving=Saving - -Pageflow_Dialog_Label_CreateFileTitle=Create File -Pageflow_Dialog_Label_FileNotExistedPart1=The file -Pageflow_Dialog_Label_FileNotExistedPart2=doesn't exist. Click OK to create it. - -#################################################### -# Generic Strings for Action and PaletteTool -#################################################### -Pageflow_Action_OpenEditor_Label=Open -Pageflow_Action_OpenEditor_ToolTip=Open Page or Action component - -Pageflow_Action_ShowPropertyView_Label=Properties -Pageflow_Action_ShowPropertyView_ToolTip=Show Properties View - -Pageflow_Action_ShowPaletteView_Label=Palette -Pageflow_Action_ShowPaletteView_ToolTip=Show Palette View - -Pageflow_Action_SyncWithFacesConfig_Label=Synchronize with Faces-config -Pageflow_Action_SyncWithFacesConfig_ToolTip=Synchronizing PageFlow Model with Faces-config - -Pageflow_Action_UpdateFacesConfig_Label=Update Faces-config -Pageflow_Action_UpdateFacesConfig_ToolTip=Update Faces-config File from The Current PageFlow - -Pageflow_PaletteTool_Group_Controls=Controls - -Pageflow_PaletteTool_Select_Label=Select -Pageflow_PaletteTool_Select_Description=Select One or More Items - -Pageflow_PaletteTool_Marquee_Label=Marquee -Pageflow_PaletteTool_Marquee_Description=Marquee One or More Items - -Pageflow_PaletteTool_Link_Label=Link -Pageflow_PaletteTool_Link_Description=Creates a Link - -Pageflow_PaletteTool_Group_Nodes=Nodes - -Pageflow_PaletteTool_Begin_Label=Begin -Pageflow_PaletteTool_Begin_Description=Creates a PageFlow Begin - -Pageflow_PaletteTool_End_Label=End -Pageflow_PaletteTool_End_Description=Creates a PageFlow End - -Pageflow_PaletteTool_Action_Label=Action -Pageflow_PaletteTool_Action_Description=Creates a PageFlow Action - -Pageflow_PaletteTool_Page_Label=Page -Pageflow_PaletteTool_Page_Description=Creates a PageFlow Page - -Pageflow_Contextmenu_Align_Label=Align - -Pageflow_Contextmenu_ShowView_Label=Show View - - - -#################################################### -# Generic Strings for Commands -#################################################### -Pageflow_Commands_AddNodeCommand_Label=Add -Pageflow_Commands_CreateNodeCommand_Label=Create -Pageflow_Commands_DeleteNodeCommand_Label=Delete - -Pageflow_Commands_ConnectionCommand_Label=Connection -Pageflow_Commands_CreateBendpointCommand_Label=Create Bendpoint -Pageflow_Commands_MoveBendpointCommand_Label=Move Bendpoint -Pageflow_Commands_DeleteBendpointCommand_Label=Delete Bendpoint - -Pageflow_Commands_OpenEditorCommand_Label=Open -Pageflow_Commands_OrphanChildCommand_Label=Orphan Child -Pageflow_Commands_UpdatePageflowCommand_Label=Update Pageflow - -Pageflow_Commands_CreateNodeCommand_SelectJSPDialog_Title=Select JSP File -Pageflow_Commands_CreateNodeCommand_SelectJSPDialog_Description=Please select a jsp file. - -#################################################### -# Generic Strings for property attribute name -#################################################### -Pageflow_Model_Attributes_comment=description -Pageflow_Model_Attributes_name=display-name -Pageflow_Model_Attributes_largeicon=large-icon -Pageflow_Model_Attributes_smallicon=small-icon - -Pageflow_Model_Attributes_action=from-action -Pageflow_Model_Attributes_path=path -Pageflow_Model_Attributes_begin=begin -Pageflow_Model_Attributes_end=end -Pageflow_Model_Attributes_configfile=config file - -Pageflow_Model_Attributes_source = from-view-id -Pageflow_Model_Attributes_target = to-view-id - -Pageflow_Model_Attributes_outcome=from-outcome -Pageflow_Model_Attributes_redirect=redirect - -Pageflow_Model_Attributes_fromaction=from-action -Pageflow_Model_Attributes_referenceLink=reference - -Pageflow_Model_Items_Pageflow=File -Pageflow_Model_Items_PFPage=Page -Pageflow_Model_Items_PFLink=Link - - -Pageflow_Property_Action_OutcomeSelectionDialog_Choice=Enter the outcome or select one from action list below: - -Pageflow_Property_Action_OutcomeSelectionDialog_Title=Outcome Selection -Pageflow_Property_Action_OutcomeSelectionDialog_JSPName=JSP File Name: -Pageflow_Property_Action_OutcomeSelectionDialog_ActionListTable_Title=Actions -Pageflow_Property_Action_OutcomeSelectionDialog_ActionListTable_Component=Component ID -Pageflow_Property_Action_OutcomeSelectionDialog_ActionListTable_Action=Action - -Pageflow_Property_Action_OutcomeSelectionDialog_Outcome=Outcome: - -#################################################### -#Pageflow validation -#################################################### -Pageflow_Validation_UndefinedOutcome=The outcome \''{0}\'' is not defined in previous page \''{1}\''. -Pageflow_Validation_NotExistedSourcePage=The source page \''{0}\'' is not existed. -Pageflow_Validation_MissingSourcePage=The source page should be specified. - -Pageflow_Validation_InvalidWebPage=The file \''{0}\'' is not valid web file. -Pageflow_Validation_NotExitedWebPage=The web page \''{0}\'' is not existed. -Pageflow_Validation_MissingWebPage=The web page's path should be specified. - -Pageflow_Validation_MissingManagedBean=The managed bean \''{0}\'' is not defined. -Pageflow_Validation_MissingAction=The action should be specified. - -ExistingPagePathDialogCellEdito_LabelText = Please enter or select a web page path: - -PageflowLinkEditPart_FromAction=fromAction: -PageflowLinkEditPart_FromOutcome=fromOutcome: diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowPaletteRoot.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowPaletteRoot.java deleted file mode 100644 index 679ca2cca..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowPaletteRoot.java +++ /dev/null @@ -1,105 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow; - -import org.eclipse.gef.palette.CombinedTemplateCreationEntry; -import org.eclipse.gef.palette.ConnectionCreationToolEntry; -import org.eclipse.gef.palette.MarqueeToolEntry; -import org.eclipse.gef.palette.PaletteDrawer; -import org.eclipse.gef.palette.PaletteGroup; -import org.eclipse.gef.palette.PaletteRoot; -import org.eclipse.gef.palette.PaletteSeparator; -import org.eclipse.gef.palette.SelectionToolEntry; -import org.eclipse.gef.palette.ToolEntry; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.util.ModelCreationFactory; - -/** - * This is the root of the palette used by pageflow editors. - */ -public class PageflowPaletteRoot extends PaletteRoot { - - /** - * Creates a new PageflowPaletteRoot instance. - */ - public PageflowPaletteRoot() { - // create root - super(); - - // a group of default control tools - // Pageflow.PaletteTool.Group.Controls = Controls - PaletteGroup controls = new PaletteGroup( - PageflowMessages.Pageflow_PaletteTool_Group_Controls); //$NON-NLS-1$ - add(controls); - - // the selection tool - // Pageflow.PaletteTool.Select.Label = Select - // Pageflow.PaletteTool.Select.Description = Select one or more items - ToolEntry tool = new SelectionToolEntry( - PageflowMessages.Pageflow_PaletteTool_Select_Label, - PageflowMessages.Pageflow_PaletteTool_Select_Description); //$NON-NLS-1$ - - controls.add(tool); - - // use selection tool as default entry - setDefaultEntry(tool); - - // the marquee selection tool - // Pageflow.PaletteTool.Marquee.Label = Marquee - // Pageflow.PaletteTool.Marquee.Description = Marquee one or more items - controls.add(new MarqueeToolEntry( - PageflowMessages.Pageflow_PaletteTool_Marquee_Label, //$NON-NLS-1$ - PageflowMessages.Pageflow_PaletteTool_Marquee_Description)); - - controls.add(new PaletteSeparator()); - - // conection creation - // Pageflow.PaletteTool.Link.Label = Link - // Pageflow.PaletteTool.Link.Description = Creates an link - ConnectionCreationToolEntry linkEntry = new ConnectionCreationToolEntry( - PageflowMessages.Pageflow_PaletteTool_Link_Label, - PageflowMessages.Pageflow_PaletteTool_Link_Description, - new ModelCreationFactory(PageflowLink.class), EditorPlugin - .getDefault().getImageDescriptor( - "facesconfig/Pageflow_Link.gif"), //$NON-NLS-1$ - EditorPlugin.getDefault().getImageDescriptor( - "facesconfig/Pageflow_Link24.gif")); //$NON-NLS-1$ - linkEntry.setUserModificationPermission(PERMISSION_FULL_MODIFICATION); - controls.add(linkEntry); - - controls.add(new PaletteSeparator()); - - // Pageflow.PaletteTool.Group.Nodes = Nodes - PaletteDrawer nodes = new PaletteDrawer( - PageflowMessages.Pageflow_PaletteTool_Group_Nodes); //$NON-NLS-1$ - add(nodes); - - // use CombinedTemplateCreationEntry which can be also dragged - CombinedTemplateCreationEntry entry; - - // Pageflow.PaletteTool.Page.Label = Page - // Pageflow.PaletteTool.Page.Description = Creates a pageflow page - entry = new CombinedTemplateCreationEntry( - PageflowMessages.Pageflow_PaletteTool_Page_Label, - PageflowMessages.Pageflow_PaletteTool_Page_Description, - PageflowPage.class, - new ModelCreationFactory(PageflowPage.class), EditorPlugin - .getDefault().getImageDescriptor( - "facesconfig/Pageflow_Page16.gif"), //$NON-NLS-1$ - EditorPlugin.getDefault().getImageDescriptor( - "facesconfig/Pageflow_Page24.gif")); //$NON-NLS-1$ - nodes.add(entry); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowTemplateTransferDropTargetListener.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowTemplateTransferDropTargetListener.java deleted file mode 100644 index 4c4a8a4df..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/PageflowTemplateTransferDropTargetListener.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow; - -import org.eclipse.gef.EditPartViewer; -import org.eclipse.gef.dnd.TemplateTransferDropTargetListener; -import org.eclipse.gef.requests.CreationFactory; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.util.ModelCreationFactory; - -/** - * This is the drop listener for template transfers from the palette. Only need - * to implement the <code>getFactory</code> method. - */ -public class PageflowTemplateTransferDropTargetListener extends - TemplateTransferDropTargetListener { - /** - * Creates a new PageflowTemplateTransferDropTargetListener instance. - * - * @param viewer - - * target pageflow editor view. - */ - public PageflowTemplateTransferDropTargetListener(EditPartViewer viewer) { - super(viewer); - } - - /* - * (non-Javadoc) - * - * @see TemplateTransferDropTargetListener#getFactory(Object) - */ - protected CreationFactory getFactory(Object template) { - if (template instanceof Class) { - return new ModelCreationFactory((Class) template); - } - return null; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/ResourceTransferDropTargetListener.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/ResourceTransferDropTargetListener.java deleted file mode 100644 index f9ca21595..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/ResourceTransferDropTargetListener.java +++ /dev/null @@ -1,211 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow; - -import org.eclipse.core.resources.IResource; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPartViewer; -import org.eclipse.gef.Request; -import org.eclipse.gef.dnd.AbstractTransferDropTargetListener; -import org.eclipse.gef.requests.CreateRequest; -import org.eclipse.gef.requests.CreationFactory; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jst.jsf.facesconfig.ui.util.WebrootUtil; -import org.eclipse.swt.dnd.DND; -import org.eclipse.swt.dnd.DropTargetEvent; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.part.FileEditorInput; -import org.eclipse.ui.part.ResourceTransfer; -import org.eclipse.ui.views.navigator.LocalSelectionTransfer; - -/** - * This is the listener for resource drag and drop operations - * - */ -public abstract class ResourceTransferDropTargetListener extends - AbstractTransferDropTargetListener { - /** the pageflow editor */ - private IEditorPart editor = null; - - /** - * Creates a new ResourceTransferDropTargetListener instance. - * - * @param viewer - - * target pageflow editor view. - */ - public ResourceTransferDropTargetListener(EditPartViewer viewer, - IEditorPart editor) { - super(viewer, ResourceTransfer.getInstance()); - - this.editor = editor; - } - - /* - * (non-Javadoc) - * - * @see AbstractTransferDropTargetListener#createTargetRequest() - */ - protected Request createTargetRequest() { - CreateRequest request = new CreateRequest(); - if (getCurrentEvent().data == null) { - request.setFactory(getFactory(null)); - } else { - IResource[] resources = (IResource[]) getCurrentEvent().data; - request.setFactory(getFactory(resources[0])); - } - return request; - } - - /** - * get the request for creating a new resource object - * - * @return - creation request - */ - protected final CreateRequest getCreateRequest() { - return (CreateRequest) getTargetRequest(); - } - - /** - * get creation factory for resource object, which should be implemented. - * - * @param obj - - * resource object - * @return - creation factory for resource object - */ - abstract protected CreationFactory getFactory(Object obj); - - /* - * (non-Javadoc) - * - * @see AbstractTransferDropTargetListener#handleDragOperationChanged() - */ - protected void handleDragOperationChanged() { - getCurrentEvent().detail = DND.DROP_COPY; - super.handleDragOperationChanged(); - } - - /** - * get the current transfered local selection object. - * - * @return - */ - private Object getCurrentLocalObject() { - ISelection sel = LocalSelectionTransfer.getInstance().getSelection(); - if (sel instanceof IStructuredSelection) { - return ((IStructuredSelection) sel).getFirstElement(); - } - return null; - } - - /* - * (non-Javadoc) - * - * @see AbstractTransferDropTargetListener#handleDragOver() - */ - protected void handleDragOver() { - if (!isValidJSFFile(getCurrentLocalObject())) { - getCurrentEvent().detail = DND.ERROR_INVALID_DATA; - } else { - getCurrentEvent().detail = DND.DROP_COPY; - } - getCurrentEvent().feedback = DND.FEEDBACK_SCROLL | DND.FEEDBACK_EXPAND; - super.handleDragOver(); - } - - /* - * (non-Javadoc) - * - * @see AbstractTransferDropTargetListener#handleDrop() - */ - protected void handleDrop() { - getCurrentEvent().detail = DND.DROP_COPY; - super.handleDrop(); - // because the handle drop can change this event to DND.DROP_NONE - if (getCurrentEvent().detail == DND.DROP_COPY) { - selectAddedObject(); - } - } - - /** - * select the new drag and drop object in the pageflow view. - */ - private void selectAddedObject() { - Object model = getCreateRequest().getNewObject(); - if (null == model) { - return; - } - EditPartViewer viewer = getViewer(); - Object editpart = viewer.getEditPartRegistry().get(model); - if (editpart instanceof EditPart) { - viewer.flush(); - viewer.select((EditPart) editpart); - // Activate the editor window - PlatformUI.getWorkbench().getActiveWorkbenchWindow() - .getActivePage().activate(editor); - } - } - - /* - * (non-Javadoc) - * - * @see AbstractTransferDropTargetListener#updateTargetRequest() - */ - protected void updateTargetRequest() { - CreateRequest request = getCreateRequest(); - request.setLocation(getDropLocation()); - } - - /** - * Allow drop if any of these types in the drop data, which can be jsp file - * or a sub folder of the webroot folder. - * - */ - private boolean isValidJSFFile(Object resource) { - if (resource == null || !(resource instanceof IResource)) { - return false; - } - - if (((IResource) resource).getProject() == ((FileEditorInput) editor - .getEditorInput()).getFile().getProject()) { - if (WebrootUtil.getWebPath(((IResource) resource).getFullPath()) - .length() > 0) { - return true; - } - } - return false; - } - - /* - * (non-Javadoc) - * - * @see AbstractTransferDropTargetListener#isEnabled() - */ - public boolean isEnabled(DropTargetEvent dropTargetEvent) { - if (super.isEnabled(dropTargetEvent)) { - if (dropTargetEvent.data != null) { - IResource[] resources = (IResource[]) dropTargetEvent.data; - // The resource should be under the same project of the current - // faces-config file - if (isValidJSFFile(resources[0])) { - return true; - } - return false; - } - // If no data, can't verify, so allow the drop - return true; - } - return false; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/AlignmentAction.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/AlignmentAction.java deleted file mode 100644 index e108d8e55..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/AlignmentAction.java +++ /dev/null @@ -1,329 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.action; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.draw2d.PositionConstants; -import org.eclipse.draw2d.geometry.PrecisionRectangle; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.gef.Request; -import org.eclipse.gef.RequestConstants; -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.commands.CompoundCommand; -import org.eclipse.gef.requests.AlignmentRequest; -import org.eclipse.gef.tools.ToolUtilities; -import org.eclipse.gef.ui.actions.GEFActionConstants; -import org.eclipse.gef.ui.actions.SelectionAction; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchPart; - -/** - * An improved alignment action to align the selected parts in different action. - * - * @author xgzhang - * @version original version is from GEF - */ -public final class AlignmentAction extends SelectionAction { - - /** - * Indicates that the bottom edges should be aligned. - */ - public static final String ID_ALIGN_BOTTOM = GEFActionConstants.ALIGN_BOTTOM; - - /** - * Indicates that the horizontal centers should be aligned. - */ - public static final String ID_ALIGN_CENTER = GEFActionConstants.ALIGN_CENTER; - - /** - * Indicates that the left edges should be aligned. - */ - public static final String ID_ALIGN_LEFT = GEFActionConstants.ALIGN_LEFT; - - /** - * Indicates that the vertical midpoints should be aligned. - */ - public static final String ID_ALIGN_MIDDLE = GEFActionConstants.ALIGN_MIDDLE; - - /** - * Indicates that the right edges should be aligned. - */ - public static final String ID_ALIGN_RIGHT = GEFActionConstants.ALIGN_RIGHT; - - /** - * Indicates that the top edges should be aligned. - */ - public static final String ID_ALIGN_TOP = GEFActionConstants.ALIGN_TOP; - - private int alignment; - - private List operationSet; - - /** - * @deprecated use AlignmentAction(IWorkbenchPart, int align) - * @param editor - * the editor - * @param align - * the alignment ID - */ - public AlignmentAction(IEditorPart editor, int align) { - this((IWorkbenchPart) editor, align); - } - - /** - * Constructs an AlignmentAction with the given part and alignment ID. The - * alignment ID must by one of: - * <UL> - * <LI>GEFActionConstants.ALIGN_LEFT - * <LI>GEFActionConstants.ALIGN_RIGHT - * <LI>GEFActionConstants.ALIGN_CENTER - * <LI>GEFActionConstants.ALIGN_TOP - * <LI>GEFActionConstants.ALIGN_BOTTOM - * <LI>GEFActionConstants.ALIGN_MIDDLE - * </UL> - * - * @param part - * the workbench part used to obtain context - * @param align - * the aligment ID. - */ - public AlignmentAction(IWorkbenchPart part, int align) { - super(part); - alignment = align; - initUI(); - } - - /** - * Returns the alignment rectangle to which all selected parts should be - * aligned. - * - * @param request - * the alignment Request - * @return the alignment rectangle - */ - protected Rectangle calculateAlignmentRectangle(Request request) { - List editparts = getOperationSet(request); - if (editparts == null || editparts.isEmpty()) { - return null; - } - GraphicalEditPart part = null; - if (alignment == PositionConstants.MIDDLE - || alignment == PositionConstants.CENTER) { - part = (GraphicalEditPart) editparts.get(editparts.size() - 1); - } else { - part = getFitnessPart(editparts); - } - Rectangle rect = new PrecisionRectangle(part.getFigure().getBounds()); - part.getFigure().translateToAbsolute(rect); - return rect; - } - - /** - * get the Fitness part in the four kinds of alignment directions - * - * @param editparts - */ - private GraphicalEditPart getFitnessPart(List editparts) { - if (alignment == PositionConstants.MIDDLE - || alignment == PositionConstants.CENTER) { - return null; - } - - int positionComparor = Integer.MAX_VALUE; - - if (alignment == PositionConstants.LEFT - || alignment == PositionConstants.TOP) { - positionComparor = Integer.MAX_VALUE; - } else if (alignment == PositionConstants.RIGHT - || alignment == PositionConstants.BOTTOM) { - positionComparor = Integer.MIN_VALUE; - } - - GraphicalEditPart fitnessPart = null; - - for (Iterator iter = editparts.iterator(); iter.hasNext();) { - GraphicalEditPart part = (GraphicalEditPart) iter.next(); - Rectangle rectPart = part.getFigure().getBounds(); - switch (alignment) { - case PositionConstants.LEFT: - if (rectPart.getLeft().x < positionComparor) { - fitnessPart = part; - positionComparor = rectPart.getLeft().x; - } - break; - - case PositionConstants.RIGHT: - if (rectPart.getRight().x > positionComparor) { - fitnessPart = part; - positionComparor = rectPart.getRight().x; - } - break; - case PositionConstants.TOP: - if (rectPart.getTop().y < positionComparor) { - fitnessPart = part; - positionComparor = rectPart.getTop().y; - } - break; - case PositionConstants.BOTTOM: - if (rectPart.getBottom().y > positionComparor) { - fitnessPart = part; - positionComparor = rectPart.getBottom().y; - } - break; - } - } - - return fitnessPart; - } - - /** - * @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled() - */ - protected boolean calculateEnabled() { - operationSet = null; - Command cmd = createAlignmentCommand(); - if (cmd == null) { - return false; - } - return cmd.canExecute(); - } - - private Command createAlignmentCommand() { - AlignmentRequest request = new AlignmentRequest( - RequestConstants.REQ_ALIGN); - request.setAlignmentRectangle(calculateAlignmentRectangle(request)); - request.setAlignment(alignment); - List editparts = getOperationSet(request); - if (editparts.size() < 2) { - return null; - } - - CompoundCommand command = new CompoundCommand(); - command.setDebugLabel(getText()); - for (int i = 0; i < editparts.size(); i++) { - EditPart editpart = (EditPart) editparts.get(i); - command.add(editpart.getCommand(request)); - } - return command; - } - - /** - * @see org.eclipse.gef.Disposable#dispose() - */ - public void dispose() { - operationSet = Collections.EMPTY_LIST; - super.dispose(); - } - - /** - * Returns the list of editparts which will participate in alignment. - * - * @param request - * the alignment request - * @return the list of parts which will be aligned - */ - protected List getOperationSet(Request request) { - if (operationSet != null) { - return operationSet; - } - List editparts = new ArrayList(getSelectedObjects()); - if (editparts.isEmpty() - || !(editparts.get(0) instanceof GraphicalEditPart)) { - return Collections.EMPTY_LIST; - } - Object primary = editparts.get(editparts.size() - 1); - editparts = ToolUtilities.getSelectionWithoutDependants(editparts); - ToolUtilities.filterEditPartsUnderstanding(editparts, request); - if (editparts.size() < 2 || !editparts.contains(primary)) { - return Collections.EMPTY_LIST; - } - EditPart parent = ((EditPart) editparts.get(0)).getParent(); - for (int i = 1; i < editparts.size(); i++) { - EditPart part = (EditPart) editparts.get(i); - if (part.getParent() != parent) { - return Collections.EMPTY_LIST; - } - } - return editparts; - } - - /** - * Initializes the actions UI presentation. - */ - protected void initUI() { - switch (alignment) { - case PositionConstants.LEFT: - setId(GEFActionConstants.ALIGN_LEFT); - setText(EditorMessages.AlignmentAction_AlignLeftAction_Label); - setToolTipText(EditorMessages.AlignmentAction_AlignLeftAction_Tooltip); - setImageDescriptor(InternalImages.DESC_HORZ_ALIGN_LEFT); - setDisabledImageDescriptor(InternalImages.DESC_HORZ_ALIGN_LEFT_DIS); - break; - - case PositionConstants.RIGHT: - setId(GEFActionConstants.ALIGN_RIGHT); - setText(EditorMessages.AlignmentAction_AlignRightAction_Label); - setToolTipText(EditorMessages.AlignmentAction_AlignRightAction_Tooltip); - setImageDescriptor(InternalImages.DESC_HORZ_ALIGN_RIGHT); - setDisabledImageDescriptor(InternalImages.DESC_HORZ_ALIGN_RIGHT_DIS); - break; - - case PositionConstants.TOP: - setId(GEFActionConstants.ALIGN_TOP); - setText(EditorMessages.AlignmentAction_AlignTopAction_Label); - setToolTipText(EditorMessages.AlignmentAction_AlignTopAction_Tooltip); - setImageDescriptor(InternalImages.DESC_VERT_ALIGN_TOP); - setDisabledImageDescriptor(InternalImages.DESC_VERT_ALIGN_TOP_DIS); - break; - - case PositionConstants.BOTTOM: - setId(GEFActionConstants.ALIGN_BOTTOM); - setText(EditorMessages.AlignmentAction_AlignBottomAction_Label); - setToolTipText(EditorMessages.AlignmentAction_AlignBottomAction_Tooltip); - setImageDescriptor(InternalImages.DESC_VERT_ALIGN_BOTTOM); - setDisabledImageDescriptor(InternalImages.DESC_VERT_ALIGN_BOTTOM_DIS); - break; - - case PositionConstants.CENTER: - setId(GEFActionConstants.ALIGN_CENTER); - setText(EditorMessages.AlignmentAction_AlignCenterAction_Label); - setToolTipText(EditorMessages.AlignmentAction_AlignCenterAction_Tooltip); - setImageDescriptor(InternalImages.DESC_HORZ_ALIGN_CENTER); - setDisabledImageDescriptor(InternalImages.DESC_HORZ_ALIGN_CENTER_DIS); - break; - - case PositionConstants.MIDDLE: - setId(GEFActionConstants.ALIGN_MIDDLE); - setText(EditorMessages.AlignmentAction_AlignMiddleAction_Label); - setToolTipText(EditorMessages.AlignmentAction_AlignMiddleAction_Tooltip); - setImageDescriptor(InternalImages.DESC_VERT_ALIGN_MIDDLE); - setDisabledImageDescriptor(InternalImages.DESC_VERT_ALIGN_MIDDLE_DIS); - break; - } - } - - /** - * @see org.eclipse.jface.action.IAction#run() - */ - public void run() { - operationSet = null; - execute(createAlignmentCommand()); - } - -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/InternalImages.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/InternalImages.java deleted file mode 100644 index 8daa9ba7a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/InternalImages.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Oracle Corporation. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Ian Trimble - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.action; - -import org.eclipse.jface.resource.ImageDescriptor; - -/** - * Supplies image descriptors, intended for internal use only. - * - * @author Ian Trimble - Oracle - */ -public class InternalImages { - - /** - * ImageDescriptor instance for center alignment image. - */ - public static final ImageDescriptor DESC_HORZ_ALIGN_CENTER; - - /** - * ImageDescriptor instance for left alignment image. - */ - public static final ImageDescriptor DESC_HORZ_ALIGN_LEFT; - - /** - * ImageDescriptor instance for right alignment image. - */ - public static final ImageDescriptor DESC_HORZ_ALIGN_RIGHT; - - /** - * ImageDescriptor instance for middle alignment image. - */ - public static final ImageDescriptor DESC_VERT_ALIGN_MIDDLE; - - /** - * ImageDescriptor instance for top alignment image. - */ - public static final ImageDescriptor DESC_VERT_ALIGN_TOP; - - /** - * ImageDescriptor instance for bottom alignment image. - */ - public static final ImageDescriptor DESC_VERT_ALIGN_BOTTOM; - - /** - * ImageDescriptor instance for center alignment image (disabled). - */ - public static final ImageDescriptor DESC_HORZ_ALIGN_CENTER_DIS; - - /** - * ImageDescriptor instance for left alignment image (disabled). - */ - public static final ImageDescriptor DESC_HORZ_ALIGN_LEFT_DIS; - - /** - * ImageDescriptor instance for right alignment image (disabled). - */ - public static final ImageDescriptor DESC_HORZ_ALIGN_RIGHT_DIS; - - /** - * ImageDescriptor instance for middle alignment image (disabled). - */ - public static final ImageDescriptor DESC_VERT_ALIGN_MIDDLE_DIS; - - /** - * ImageDescriptor instance for top alignment image (disabled). - */ - public static final ImageDescriptor DESC_VERT_ALIGN_TOP_DIS; - - /** - * ImageDescriptor instance for bottom alignment image (disabled). - */ - public static final ImageDescriptor DESC_VERT_ALIGN_BOTTOM_DIS; - - static { - DESC_VERT_ALIGN_BOTTOM = createDescriptor("icons/alignbottom.gif"); //$NON-NLS-1$ - DESC_HORZ_ALIGN_CENTER = createDescriptor("icons/aligncenter.gif"); //$NON-NLS-1$ - DESC_HORZ_ALIGN_LEFT = createDescriptor("icons/alignleft.gif"); //$NON-NLS-1$ - DESC_VERT_ALIGN_MIDDLE = createDescriptor("icons/alignmid.gif"); //$NON-NLS-1$ - DESC_HORZ_ALIGN_RIGHT = createDescriptor("icons/alignright.gif"); //$NON-NLS-1$ - DESC_VERT_ALIGN_TOP = createDescriptor("icons/aligntop.gif"); //$NON-NLS-1$ - DESC_VERT_ALIGN_BOTTOM_DIS = createDescriptor("icons/alignbottom_d.gif"); //$NON-NLS-1$ - DESC_HORZ_ALIGN_CENTER_DIS = createDescriptor("icons/aligncenter_d.gif"); //$NON-NLS-1$ - DESC_HORZ_ALIGN_LEFT_DIS = createDescriptor("icons/alignleft_d.gif"); //$NON-NLS-1$ - DESC_VERT_ALIGN_MIDDLE_DIS = createDescriptor("icons/alignmid_d.gif"); //$NON-NLS-1$ - DESC_HORZ_ALIGN_RIGHT_DIS = createDescriptor("icons/alignright_d.gif"); //$NON-NLS-1$ - DESC_VERT_ALIGN_TOP_DIS = createDescriptor("icons/aligntop_d.gif"); //$NON-NLS-1$ - } - - private static ImageDescriptor createDescriptor(String filename) { - return ImageDescriptor.createFromFile(InternalImages.class, filename); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/OpenEditorAction.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/OpenEditorAction.java deleted file mode 100644 index 7c27eabd4..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/OpenEditorAction.java +++ /dev/null @@ -1,122 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.action; - -import java.util.List; - -import org.eclipse.gef.EditPart; -import org.eclipse.gef.Request; -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.commands.CompoundCommand; -import org.eclipse.gef.ui.actions.SelectionAction; -import org.eclipse.jst.jsf.facesconfig.ui.FacesConfigEditor; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowMessages; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; -import org.eclipse.ui.IWorkbenchPart; - -/** - * - * This is the Action for opening a JSP page in the default JSP Editor from a - * Pageflow Diagram - * - */ -public class OpenEditorAction extends SelectionAction { - /** The name of the request */ - public static final String OPEN_EDITOR_REQUEST = PageflowMessages.Pageflow_Commands_OpenEditorCommand_Label; - - /** The request */ - Request request; - - /** - * The constructor - * - * @param part - - * the IWorkbenchPart - */ - public OpenEditorAction(IWorkbenchPart part) { - super(part); - request = new Request(OPEN_EDITOR_REQUEST); - // Pageflow.Action.OpenEditor.Label = Edit Page - setText(PageflowMessages.Pageflow_Action_OpenEditor_Label); - setId(FacesConfigEditor.EDITOR_ID); - // Pageflow.Action.OpenEditor.ToolTip = Edit this page - setToolTipText(PageflowMessages.Pageflow_Action_OpenEditor_ToolTip); - } - - /** - * Determines if the action can be enabled - * - * @return boolean - the enabled state - */ - protected boolean calculateEnabled() { - return canPerformAction(); - } - - /** - * Determines if the action can be performed - * - * @return boolean - the perform state - */ - private boolean canPerformAction() { - if (getSelectedObjects().isEmpty()) { - return false; - } - List parts = getSelectedObjects(); - for (int i = 0; i < parts.size(); i++) { - Object o = parts.get(i); - if (!(o instanceof EditPart)) { - return false; - } - EditPart part = (EditPart) o; - if (!(part.getModel() instanceof PageflowPage)) { - return false; - } - } - return true; - } - - /** - * Returns the command for the action - * - * @return Command - the action command - */ - private Command getCommand() { - List editparts = getSelectedObjects(); - CompoundCommand cc = new CompoundCommand(); - cc.setDebugLabel(OPEN_EDITOR_REQUEST); - for (int i = 0; i < editparts.size(); i++) { - EditPart part = (EditPart) editparts.get(i); - cc.add(part.getCommand(request)); - } - return cc; - } - - /** - * Runs the command - */ - public void run() { - execute(getCommand()); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.ui.actions.WorkbenchPartAction#execute(org.eclipse.gef.commands.Command) - */ - protected void execute(Command command) { - if (command == null || !command.canExecute()) { - return; - } - command.execute(); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/ShowPropertyViewAction.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/ShowPropertyViewAction.java deleted file mode 100644 index 320660c5d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/ShowPropertyViewAction.java +++ /dev/null @@ -1,120 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.action; - -import java.util.List; - -import org.eclipse.gef.EditPart; -import org.eclipse.gef.ui.actions.SelectionAction; -import org.eclipse.jst.jsf.common.ui.internal.logging.Logger; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowMessages; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; - -/** - * - * This is the Action for opening a JSP page in the default JSP Editor from a - * Pageflow Diagram - * - * @author Xiao-guang Zhang - */ -public class ShowPropertyViewAction extends SelectionAction { - /** log instance */ - private static final Logger log = EditorPlugin - .getLogger(ShowPropertyViewAction.class); - - /** The ID of the action */ - public static final String SHOW_PROPERTY_VIEW = "org.eclipse.jst.jsf.facesconfig.ui.pageflow.action.ShowPropertyViewAction"; //$NON-NLS-1$ - - /** - * The constructor - * - * @param part - - * the IWorkbenchPart - */ - public ShowPropertyViewAction(IWorkbenchPart part) { - super(part); - // Pageflow.Action.ShowPropertyView.Label = Properties - setText(PageflowMessages.Pageflow_Action_ShowPropertyView_Label); //$NON-NLS-1$ - setId(SHOW_PROPERTY_VIEW); - // Pageflow.Action.ShowPropertyView.ToolTip = Show properties - setToolTipText(PageflowMessages.Pageflow_Action_ShowPropertyView_ToolTip); //$NON-NLS-1$ - } - - /** - * Determines if the action can be enabled - * - * @return boolean - the enabled state - */ - protected boolean calculateEnabled() { - return canPerformAction(); - } - - /** - * Determines if the action can be performed - * - * @return boolean - the perform state - */ - private boolean canPerformAction() { - if (getSelectedObjects().isEmpty()) { - return false; - } - List parts = getSelectedObjects(); - for (int i = 0; i < parts.size(); i++) { - Object o = parts.get(i); - if (!(o instanceof EditPart)) { - return false; - } - EditPart part = (EditPart) o; - if (!((part.getModel() instanceof PageflowElement))) { - return false; - } - } - return true; - } - - /** - * Runs the command - */ - public void run() { - List editparts = getSelectedObjects(); - if (editparts.size() > 0) { - EditPart part = (EditPart) editparts.get(0); - // execute(getCommand()); - if (part.getModel() instanceof PageflowElement) { - // ensure the visibility of the palette view and property veiw. - IWorkbenchWindow dw = PlatformUI.getWorkbench() - .getActiveWorkbenchWindow(); - IWorkbenchPage page = dw.getActivePage(); - if (page != null) { - try { - page.showView("org.eclipse.ui.views.PropertySheet"); - } catch (PartInitException e) { - // Pageflow.PageflowEditor.Error.canNotShowPropertyView - // = Failed to show property sheet view. - log - .error( - "Pageflow.PageflowEditor.Error.canNotShowPropertyView", - e); - } - - } - } - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/icons/alignbottom.gif b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/icons/alignbottom.gif Binary files differdeleted file mode 100644 index 9eea5581b..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/icons/alignbottom.gif +++ /dev/null diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/icons/alignbottom_d.gif b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/icons/alignbottom_d.gif Binary files differdeleted file mode 100644 index 1c62797ec..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/icons/alignbottom_d.gif +++ /dev/null diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/icons/aligncenter.gif b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/icons/aligncenter.gif Binary files differdeleted file mode 100644 index 4e8c94a88..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/icons/aligncenter.gif +++ /dev/null diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/icons/aligncenter_d.gif b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/icons/aligncenter_d.gif Binary files differdeleted file mode 100644 index ceeafb780..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/icons/aligncenter_d.gif +++ /dev/null diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/icons/alignleft.gif b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/icons/alignleft.gif Binary files differdeleted file mode 100644 index 55cecc20e..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/icons/alignleft.gif +++ /dev/null diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/icons/alignleft_d.gif b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/icons/alignleft_d.gif Binary files differdeleted file mode 100644 index 60fcc8f5c..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/icons/alignleft_d.gif +++ /dev/null diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/icons/alignmid.gif b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/icons/alignmid.gif Binary files differdeleted file mode 100644 index 5f13c93d4..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/icons/alignmid.gif +++ /dev/null diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/icons/alignmid_d.gif b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/icons/alignmid_d.gif Binary files differdeleted file mode 100644 index 2f7534e6f..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/icons/alignmid_d.gif +++ /dev/null diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/icons/alignright.gif b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/icons/alignright.gif Binary files differdeleted file mode 100644 index f6ead1580..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/icons/alignright.gif +++ /dev/null diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/icons/alignright_d.gif b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/icons/alignright_d.gif Binary files differdeleted file mode 100644 index 0495ed5d6..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/icons/alignright_d.gif +++ /dev/null diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/icons/aligntop.gif b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/icons/aligntop.gif Binary files differdeleted file mode 100644 index 2f9ceeb11..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/icons/aligntop.gif +++ /dev/null diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/icons/aligntop_d.gif b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/icons/aligntop_d.gif Binary files differdeleted file mode 100644 index 9f1b49b1c..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/action/icons/aligntop_d.gif +++ /dev/null diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/AbstractBatchEditCommand.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/AbstractBatchEditCommand.java deleted file mode 100644 index 4cd06f003..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/AbstractBatchEditCommand.java +++ /dev/null @@ -1,93 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.command; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.gef.commands.Command; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.synchronization.FC2PFTransformer; - -/** - * A batched edit command will enable adapters to interven before and after a - * set of operations was done by sending notification to the adapters. - * - * @author hmeng - */ - -public abstract class AbstractBatchEditCommand extends Command { - Pageflow pageflow; - - public AbstractBatchEditCommand(Pageflow pageflow) { - super(); - this.pageflow = pageflow; - } - - public AbstractBatchEditCommand(Pageflow pageflow, String label) { - super(label); - this.pageflow = pageflow; - } - - public Pageflow getPageflow() { - return pageflow; - } - - /** - * The subclass should extend methods doXXX only. - */ - final public void execute() { - preExecute(); - doExecute(); - postExecute(); - } - - final public void redo() { - doRedo(); - } - - final public void undo() { - preExecute(); - doUndo(); - postExecute(); - } - - abstract public void doExecute(); - - public void doRedo() { - execute(); - } - - abstract void doUndo(); - - final void preExecute() { - getPageflow().eNotify( - new ENotificationImpl((InternalEObject) getPageflow(), - FC2PFTransformer.MY_NOTIFICATION_TYPE, - PageflowPackage.PAGEFLOW, null, null)); - } - - final protected void postExecute() { - getPageflow().eNotify( - new ENotificationImpl((InternalEObject) getPageflow(), - FC2PFTransformer.MY_NOTIFICATION_TYPE1, - PageflowPackage.PAGEFLOW, null, null)); - notifyPageflow(getPageflow()); - } - - protected void notifyPageflow(Pageflow pageflow_) { - pageflow_.notifyModelChanged(new ENotificationImpl( - (InternalEObject) pageflow_, Notification.ADD, - PageflowPackage.PAGEFLOW, null, null)); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/AddConnectionCommand.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/AddConnectionCommand.java deleted file mode 100644 index 149da0bdd..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/AddConnectionCommand.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.command; - -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.layout.PageflowLayoutManager; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.util.PageflowValidation; - -/** - * Add a new connection - * - * @author hmeng - * - */ -public class AddConnectionCommand extends ConnectionCommand { - - public boolean canExecute() { - // if user don't set PFLink object before, this command can't be - // executed. - if (link == null) { - return false; - } - - // It is a connection create command - if (oldSource == null && oldTarget == null) { - // It is a connection create command - // Source and target must be pointing to some - // real connection point - if (source == null || target == null) { - return false; - } - - if (!PageflowValidation.getInstance().isValidLinkForCreation( - source, target)) { - return false; - } - } - return true; - } - - public void doExecute() { - // It is a connection create command - if (canExecute() && oldSource == null && oldTarget == null) { - Pageflow pageflow = null; - // Get a reference to the pageflow - if (source != null) { - pageflow = source.getPageflow(); - } else if (target != null) { - pageflow = target.getPageflow(); - } - pageflow.connect(source, target, link); - - // self loop link - if (source == target) { - PageflowLayoutManager.updateSelfLoopLink(link); - } - } - } - - public void redo() { - // TODO Auto-generated method stub - super.redo(); - } - - public void undo() { - if (canExecute()) { - // It was a connection create command - if (oldSource == null && oldTarget == null) { - - Pageflow pageflow = null; - // Get a reference to the pageflow - if (source != null) { - pageflow = source.getPageflow(); - } else if (target != null) { - pageflow = target.getPageflow(); - } - - // Ensure that link knows nothing about nodes anymore. - link.setSource(null); - link.setTarget(null); - // Remove link from pageflow - pageflow.getLinks().remove(link); - } - } - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/AddNodeCommand.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/AddNodeCommand.java deleted file mode 100644 index 2fcc0d5e1..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/AddNodeCommand.java +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.command; - -import org.eclipse.gef.commands.Command; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowMessages; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode; - -/** - * This is the add command for pageflow editpart - * - */ -public class AddNodeCommand extends Command { - /** Pageflow node including Page, action, begin, end. */ - private PageflowNode child; - - /** parent Pageflow */ - private Pageflow parent; - - /** index of pageflow nodes */ - private int index = -1; - - public AddNodeCommand() { - // Pageflow.Commands.AddNodeCommand.Label = add - super(PageflowMessages.Pageflow_Commands_AddNodeCommand_Label); - } - - /* - * (non-Javadoc) - * - * @see Command#execute() - */ - public void execute() { - if (index < 0) { - parent.getNodes().add(child); - } else { - parent.getNodes().add(index, child); - } - } - - /* - * (non-Javadoc) - * - * @see Command#redo() - */ - public void redo() { - if (index < 0) { - parent.getNodes().add(child); - } else { - parent.getNodes().add(index, child); - } - } - - /* - * (non-Javadoc) - * - * @see Command#undo() - */ - public void undo() { - parent.getNodes().remove(child); - } - - /** - * get parent pageflow of the node. - * - */ - public Pageflow getParent() { - return parent; - } - - /** - * Set the child pageflow node - * - * @param subpart - - * child pageflow node - */ - public void setChild(PageflowNode subpart) { - child = subpart; - } - - /** - * Creates a new AbstractEditorPage instance. - * - * @param i - - * index of pageflow node - */ - public void setIndex(int i) { - index = i; - } - - /** - * Set the new parent pageflow - * - * @param newParent - - * parent pageflow - */ - public void setParent(Pageflow newParent) { - parent = newParent; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/BendpointCommand.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/BendpointCommand.java deleted file mode 100644 index cf03f6c2b..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/BendpointCommand.java +++ /dev/null @@ -1,140 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.command; - -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.gef.commands.Command; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink; - -/** - * base class for bend point commands. - * - */ -public abstract class BendpointCommand extends Command { - /** the index of the bend point */ - protected int index; - - /** the location of the bendpoint */ - protected Point location; - - /** the parent link */ - protected PageflowLink link; - - /** relative dimension between the bendpoint with start point of the pflink */ - private Dimension dimStart; - - /** relative dimension between the bendpoint with end point of the pflink */ - private Dimension dimEnd; - - public BendpointCommand(String label) { - super(label); - } - - /** - * get the dimension between the bendpoint and start point - * - * @return - the start dimension - */ - protected Dimension getFirstRelativeDimension() { - return dimStart; - } - - /** - * get the dimension between the bendpoint and end point - * - * @return - the end dimension - */ - protected Dimension getSecondRelativeDimension() { - return dimEnd; - } - - /** - * get the index of the bend point - * - * @return - the index - */ - protected int getIndex() { - return index; - } - - /** - * get the location of the bend point - * - * @return - the index - */ - protected Point getLocation() { - return location; - } - - /** - * get the parent link - * - * @return - parent link - */ - protected PageflowLink getPFLink() { - return link; - } - - /* - * (non-Javadoc) - * - * @see Command#redo() - */ - public void redo() { - execute(); - } - - /** - * set the relative dimensions of the bendpoint - * - * @param dim1 - - * the dimension between the bendpoint and start point - * @param dim2 - - * the dimension between the bendpoint and end point - */ - public void setRelativeDimensions(Dimension dim1, Dimension dim2) { - dimStart = dim1; - dimEnd = dim2; - } - - /** - * set the index of the bendpoint in the bendpoint list - * - * @param i - - * index - */ - public void setIndex(int i) { - index = i; - } - - /** - * set the location of the bendpoing - * - * @param p - - * new location - */ - public void setLocation(Point p) { - location = p; - } - - /** - * set the parent link - * - * @param newLink - - * new parent pflink - */ - public void setPFLink(PageflowLink newLink) { - link = newLink; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/ConnectionCommand.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/ConnectionCommand.java deleted file mode 100644 index 27b1c183f..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/ConnectionCommand.java +++ /dev/null @@ -1,148 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.command; - -import org.eclipse.gef.commands.Command; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowMessages; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.synchronization.TransformUtil; - -/** - * This is the connection command for pageflow editpart - * - * @author Xiao-guang Zhang, hmeng - */ -public abstract class ConnectionCommand extends Command { - /** Old source pageflow node */ - protected PageflowNode oldSource; - - /** Old target pageflow node */ - protected PageflowNode oldTarget; - - /** New source pageflow node */ - protected PageflowNode source; - - /** New target pageflow node */ - protected PageflowNode target; - - /** pageflow link */ - protected PageflowLink link; - - public ConnectionCommand() { - super(PageflowMessages.Pageflow_Commands_ConnectionCommand_Label); - } - - /* - * (non-Javadoc) - * - * @see Command#canExecute() - */ - public boolean canExecute() { - return TransformUtil.isValidPageflowElement(link); - } - - protected void doExecute() { - // do nothing; sub-class can over-ride - } - - /* - * (non-Javadoc) - * - * @see Command#execute() - */ - public final void execute() { - if (canExecute()) { - doExecute(); - } else { - link = null; - } - } - - /* - * (non-Javadoc) - * - * @see Command#redo() - */ - public void redo() { - execute(); - } - - /* - * (non-Javadoc) - * - * @see ommand#undo() - */ - public void undo() { - // do nothing - } - - /** - * Get the source pageflow node - * - * @return - the source pageflow node - */ - public PageflowNode getSource() { - return source; - } - - /** - * Get the target pageflow node - * - * @return - the target pageflow node. - */ - public PageflowNode getTarget() { - return target; - } - - /** - * Get the pageflow link - * - * @return - the pageflow link. - */ - public PageflowLink getPFLink() { - return link; - } - - /** - * Set the source pageflow node - * - * @param newSource - - * new source pageflow node - */ - public void setSource(PageflowNode newSource) { - source = newSource; - } - - /** - * Set the target pageflow node - * - * @param newTarget - - * new target pageflow node - */ - public void setTarget(PageflowNode newTarget) { - target = newTarget; - } - - /** - * Set the pageflow link - * - * @param link - - * new pageflow link - */ - public void setPFLink(PageflowLink link) { - this.link = link; - oldSource = link.getSource(); - oldTarget = link.getTarget(); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/ConnectionCommandFactory.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/ConnectionCommandFactory.java deleted file mode 100644 index 61a6c16bc..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/ConnectionCommandFactory.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.command; - -import org.eclipse.gef.Request; -import org.eclipse.gef.RequestConstants; - -/** - * The factory helps to create connection commands. - * - * @author hmeng - * - */ -public class ConnectionCommandFactory { - public static ConnectionCommand createCommand(Request request) { - ConnectionCommand command = null; - if (request.getType() == RequestConstants.REQ_CONNECTION_START - || request.getType() == RequestConstants.REQ_CONNECTION_END) { - command = new AddConnectionCommand(); - } else if (request.getType() == RequestConstants.REQ_RECONNECT_SOURCE - || request.getType() == RequestConstants.REQ_RECONNECT_TARGET) { - command = new ReconnectConnectionCommand(); - } else if (request.getType() == RequestConstants.REQ_DELETE) { - command = new DeleteConnectionCommand(); - } - return command; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/CreateBendpointCommand.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/CreateBendpointCommand.java deleted file mode 100644 index 0de57b97e..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/CreateBendpointCommand.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.command; - -import java.util.Map; - -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowMessages; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowFactory; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage; - -/** - * Create a new bend point command - * - */ -public class CreateBendpointCommand extends BendpointCommand { - public CreateBendpointCommand() { - // Pageflow.Commands.CreateBendpointCommand.Label = Create Bendpoint - super(PageflowMessages.Pageflow_Commands_CreateBendpointCommand_Label); - - } - - /* - * (non-Javadoc) - * - * @see Command#execute() - */ - public void execute() { - Map registry = EPackage.Registry.INSTANCE; - String pageflowURI = PageflowPackage.eNS_URI; - PageflowPackage pageflowPackage = (PageflowPackage) registry - .get(pageflowURI); - PageflowFactory factory = pageflowPackage.getPageflowFactory(); - PageflowLinkBendpoint _newBendpoint = factory.createPFLinkBendpoint(); - - _newBendpoint.setRelativeDimensions(getFirstRelativeDimension(), - getSecondRelativeDimension()); - getPFLink().insertBendpoint(getIndex(), _newBendpoint); - super.execute(); - } - - /* - * (non-Javadoc) - * - * @see Command#undo() - */ - public void undo() { - super.undo(); - getPFLink().removeBendpoint(getIndex()); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/CreateNodeCommand.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/CreateNodeCommand.java deleted file mode 100644 index 723e1fcf2..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/CreateNodeCommand.java +++ /dev/null @@ -1,252 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.command; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.commands.Command; -import org.eclipse.jface.window.Window; -import org.eclipse.jst.jsf.common.ui.internal.dialogs.CommonResourceDialog; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowMessages; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.util.PageflowValidation; -import org.eclipse.jst.jsf.facesconfig.ui.util.WebrootUtil; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbenchWindow; - -/** - * This is the creation command for pageflow editpart - * - * @author Xiao-guang Zhang - */ -public class CreateNodeCommand extends Command implements IPreExecuteCommand { - private static final String UNNAMED_NODE = "unnamed"; - - /** new pageflow node */ - private PageflowNode child; - - /** size of pageflow node figure */ - private Rectangle rect; - - /** parent pageflow */ - private Pageflow parent; - - /** index of pageflow nodes */ - // private int _index = -1; - public CreateNodeCommand() { - // Pageflow.Commands.CreateNodeCommand.Label = Create new node - super(PageflowMessages.Pageflow_Commands_CreateNodeCommand_Label); - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.commands.Command#canExecute() - */ - public boolean canExecute() { - return child != null && parent != null; - } - - /* - * (non-Javadoc) - * - * @see Command#execute() - */ - public void execute() { - if (rect != null) { - child.setX(rect.x); - child.setY(rect.y); - if (!rect.isEmpty()) { - child.setHeight(rect.getSize().height); - child.setWidth(rect.getSize().width); - } - } - - if (child.getName() == UNNAMED_NODE) { - child.setName(parent.getDefaultNodeName(child.getClass())); - } - - parent.getNodes().add(child); - } - - /* - * (non-Javadoc) - * - * @see Command#redo() - */ - public void redo() { - if (rect != null) { - child.setX(rect.x); - child.setY(rect.y); - if (!rect.isEmpty()) { - child.setHeight(rect.getSize().height); - child.setWidth(rect.getSize().width); - } - } - - parent.getNodes().add(child); - - } - - /* - * (non-Javadoc) - * - * @see Command#undo() - */ - public void undo() { - parent.getNodes().remove(child); - } - - /** - * select a jsp page in current project. - * - * @return - */ - private boolean selectJSPPage() { - - Shell shell = null; - IWorkbenchWindow workbenchWindow = EditorPlugin - .getActiveWorkbenchWindow(); - if (workbenchWindow.getShell() != null) { - shell = workbenchWindow.getShell(); - } else { - shell = new Shell(); - } - IProject project = WebrootUtil.getProject(getParent()); - - CommonResourceDialog dialog = new CommonResourceDialog(shell, project, - SWT.NONE); - - dialog - .setTitle(PageflowMessages.Pageflow_Commands_CreateNodeCommand_SelectJSPDialog_Title); - dialog.setSuffixs(WebrootUtil.getJSPFileExtensions()); - dialog - .setResourceDescription(PageflowMessages.Pageflow_Commands_CreateNodeCommand_SelectJSPDialog_Description); - - if (dialog.open() == Window.OK) { - Object[] result = dialog.getResult(); - if (result != null) { - IFile jspFile = (IFile) result[0]; - if (jspFile != null) { - // get the project path for the new created file, i.e., - // /project/webroot/*.jsp - String jsfSelection = WebrootUtil.getWebPath(jspFile - .getFullPath()); - if (jsfSelection != null && jsfSelection.length() > 0) { - if (PageflowValidation.getInstance().isExistedPage( - this.parent, jsfSelection)) { - // Pageflow.PageflowEditor.Alert.DNDResourceTitle = - // Pageflow Creation Error - // Pageflow.PageflowEditor.Alert.ExistingPage = The - // web page {0} is already existed in current - // PageFlow. - EditorPlugin - .getAlerts() - .error( - "Pageflow.PageflowEditor.Alert.DNDResourceTitle", - "Pageflow.PageflowEditor.Alert.ExistingPage", - jsfSelection); - return false; - } - - ((PageflowPage) (child)).setPath(jsfSelection); - ((PageflowPage) (child)).setName(WebrootUtil - .getPageNameFromWebPath(jsfSelection)); - } - - return true; - } - } - } - return false; - } - - /** - * call the JSF wizard to create a new jsf page. - * - * - */ - public Pageflow getParent() { - return parent; - } - - /** - * set the child node - * - * @param subpart - - * new child pageflow node - */ - public void setChild(PageflowNode subpart) { - child = subpart; - } - - /** - * set the location of the new pageflow node - * - * @param r - - * location of the new pageflow node - */ - public void setLocation(Rectangle r) { - rect = r; - } - - /** - * set the parent pageflow - * - * @param newParent - - * the new parent pageflow - */ - public void setParent(Pageflow newParent) { - parent = newParent; - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.commands.IPreExecuteCommand#preExecute() - */ - public boolean preExecute() { - // note that the model adds the ports to the node in this call - // pop up the new the wizard to create the new jsf file - if (child instanceof PageflowPage) { - // if the new page's file path is not empty, i.e., drag a file from - // resource navigator view - if (null != ((PageflowPage) child).getPath()) { - if (PageflowValidation.getInstance().isExistedPage(parent, - (PageflowPage) child)) { - // Pageflow.PageflowEditor.Alert.DNDResourceTitle = Pageflow - // Creation Error - // Pageflow.PageflowEditor.Alert.ExistingPage = The web page - // {0} is already existed in current PageFlow. - EditorPlugin.getAlerts().error( - "Pageflow.PageflowEditor.Alert.DNDResourceTitle", - "Pageflow.PageflowEditor.Alert.ExistingPage", - ((PageflowPage) child).getPath()); - return false; - } - } else - // create a new jsf page from scratch - { - // return createNewJSFPage(); - return selectJSPPage(); - } - } - return true; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/DelegatingCommandStack.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/DelegatingCommandStack.java deleted file mode 100644 index 56b21a432..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/DelegatingCommandStack.java +++ /dev/null @@ -1,262 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.command; - -import java.util.EventObject; - -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.commands.CommandStack; -import org.eclipse.gef.commands.CommandStackListener; -import org.eclipse.gef.commands.UnexecutableCommand; - -/** - * This is a delegating command stack, which delegates everything to another - * CommandStack except event listners. - * <p> - * Event listeners registered to a <code>DelegatingCommandStack</code> will be - * informed whenever the underlying <code>CommandStack</code> changes. They - * will not be registered to the underlying <code>CommandStack</code> directly - * but they will be informed about change events of them. - * - */ -public class DelegatingCommandStack extends CommandStack implements - CommandStackListener { - /** the empty object array */ - private static final Object[] EMPTY_OBJECT_ARRAY = new Object[] {}; - - /** the current command stack */ - private CommandStack currentCommandStack = null; - - /** - * Returns the current <code>CommandStack</code>. - * - * @return - the current <code>CommandStack</code> - */ - public CommandStack getCurrentCommandStack() { - return currentCommandStack; - } - - /** - * Sets the current <code>CommandStack</code>. - * - * @param stack - - * the <code>CommandStack</code> to set - */ - public void setCurrentCommandStack(CommandStack stack) { - if (currentCommandStack == stack) { - return; - } - - // remove from old command stack - if (null != currentCommandStack) { - currentCommandStack.removeCommandStackListener(this); - } - - // set new command stack - currentCommandStack = stack; - - if (currentCommandStack != null) { - // watch new command stack - currentCommandStack.addCommandStackListener(this); - - // the command stack changed - notifyListeners(); - } - } - - /* - * (non-Javadoc) - * - * @see CommandStack#canRedo() - */ - public boolean canRedo() { - if (null == currentCommandStack) { - return false; - } - - return currentCommandStack.canRedo(); - } - - /* - * (non-Javadoc) - * - * @see CommandStack#canUndo() - */ - public boolean canUndo() { - if (null == currentCommandStack) { - return false; - } - - return currentCommandStack.canUndo(); - } - - /* - * (non-Javadoc) - * - * @see CommandStack#dispose() - */ - public void dispose() { - if (null != currentCommandStack) { - currentCommandStack.dispose(); - } - } - - /* - * (non-Javadoc) - * - * @see CommandStack#execute(org.eclipse.gef.commands.Command) - */ - public void execute(Command command) { - if (null != currentCommandStack) { - currentCommandStack.execute(command); - } - } - - /* - * (non-Javadoc) - * - * @see CommandStack#flush() - */ - public void flush() { - if (null != currentCommandStack) { - currentCommandStack.flush(); - } - } - - /* - * (non-Javadoc) - * - * @see CommandStack#getCommands() - */ - public Object[] getCommands() { - if (null == currentCommandStack) { - return EMPTY_OBJECT_ARRAY; - } - - return currentCommandStack.getCommands(); - } - - /* - * (non-Javadoc) - * - * @see CommandStack#getRedoCommand() - */ - public Command getRedoCommand() { - if (null == currentCommandStack) { - return UnexecutableCommand.INSTANCE; - } - - return currentCommandStack.getRedoCommand(); - } - - /* - * (non-Javadoc) - * - * @see CommandStack#getUndoCommand() - */ - public Command getUndoCommand() { - if (null == currentCommandStack) { - return UnexecutableCommand.INSTANCE; - } - - return currentCommandStack.getUndoCommand(); - } - - /* - * (non-Javadoc) - * - * @see CommandStack#getUndoLimit() - */ - public int getUndoLimit() { - if (null == currentCommandStack) { - return -1; - } - - return currentCommandStack.getUndoLimit(); - } - - /* - * (non-Javadoc) - * - * @see CommandStack#isDirty() - */ - public boolean isDirty() { - if (null == currentCommandStack) { - return false; - } - - return currentCommandStack.isDirty(); - } - - /* - * (non-Javadoc) - * - * @see CommandStack#markSaveLocation() - */ - public void markSaveLocation() { - if (null != currentCommandStack) { - currentCommandStack.markSaveLocation(); - } - } - - /* - * (non-Javadoc) - * - * @see CommandStack#redo() - */ - public void redo() { - if (null != currentCommandStack) { - currentCommandStack.redo(); - } - } - - /* - * (non-Javadoc) - * - * @see CommandStack#setUndoLimit(int) - */ - public void setUndoLimit(int undoLimit) { - if (null != currentCommandStack) { - currentCommandStack.setUndoLimit(undoLimit); - } - } - - /* - * (non-Javadoc) - * - * @see CommandStack#undo() - */ - public void undo() { - if (null != currentCommandStack) { - currentCommandStack.undo(); - } - } - - /* - * (non-Javadoc) - * - * @see Object#toString() - */ - public String toString() { - return "DelegatingCommandStack(" + currentCommandStack + ")"; - } - - /* - * (non-Javadoc) - * - * @see CommandStackListener#commandStackChanged(java.util.EventObject) - */ - public void commandStackChanged(EventObject event) { - notifyListeners(); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/DeleteBendpointCommand.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/DeleteBendpointCommand.java deleted file mode 100644 index 556389edc..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/DeleteBendpointCommand.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.command; - -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowMessages; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint; - -/** - * - */ -public class DeleteBendpointCommand extends BendpointCommand { - - /** the deleting bendpoint */ - private PageflowLinkBendpoint bendpoint; - - public DeleteBendpointCommand() { - - // Pageflow.Commands.DeleteBendpointCommand.Label = Delete Bendpoint - super(PageflowMessages.Pageflow_Commands_DeleteBendpointCommand_Label); - - } - - /* - * (non-Javadoc) - * - * @see Command#execute() - */ - public void execute() { - super.execute(); - bendpoint = (PageflowLinkBendpoint) getPFLink().getBendPoints().get( - getIndex()); - getPFLink().removeBendpoint(getIndex()); - } - - /* - * (non-Javadoc) - * - * @see Command#undo() - */ - public void undo() { - super.undo(); - getPFLink().insertBendpoint(getIndex(), bendpoint); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/DeleteConnectionCommand.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/DeleteConnectionCommand.java deleted file mode 100644 index dd22437fd..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/DeleteConnectionCommand.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.command; - -/** - * Delete a connection. - * - * @author hmeng - * - */ -public class DeleteConnectionCommand extends ConnectionCommand { - - public boolean canExecute() { - return link != null; - } - - protected void doExecute() { - // It is a delete connection command - if (link != null) { - link.setSource(null); - link.setTarget(null); - oldSource.getPageflow().getLinks().remove(link); - link.eAdapters().clear(); - } - } - - public void undo() { - // It is a delete connection command - if (canExecute()) { - link.setSource(oldSource); - link.setTarget(oldTarget); - oldSource.getPageflow().getLinks().add(link); - } - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/DeleteNodeCommand.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/DeleteNodeCommand.java deleted file mode 100644 index c632e25f1..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/DeleteNodeCommand.java +++ /dev/null @@ -1,186 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.command; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowMessages; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode; - -/** - * This is the delete command for pageflow editpart - * - */ -public class DeleteNodeCommand extends AbstractBatchEditCommand { - /** the deleting pageflow node */ - private PageflowNode child; - - /** parent pageflow */ - private Pageflow parent; - - /** index of pageflow nodes */ - private int index = -1; - - /** source connections with the deleting node */ - private List sourceConnections = new ArrayList(); - - private List sourceConnectionSources = new ArrayList(); - - private List sourceConnectionTargets = new ArrayList(); - - /** target connections with the deleting node */ - private List targetConnections = new ArrayList(); - - private List targetConnectionSources = new ArrayList(); - - private List targetConnectionTargets = new ArrayList(); - - public DeleteNodeCommand(Pageflow pageflow) { - // Pageflow.Commands.DeleteNodeCommand.Label = Delete - super(pageflow, PageflowMessages.Pageflow_Commands_DeleteNodeCommand_Label); - - } - - /* - * (non-Javadoc) - * - * @see Command#execute() - */ - public void doExecute() { - primExecute(); - } - - /* - * (non-Javadoc) - * - * @see Command#redo() - */ - public void doRedo() { - primExecute(); - } - - /* - * (non-Javadoc) - * - * @see Command#undo() - */ - public void doUndo() { - parent.getNodes().add(index, child); - restoreConnections(child); - } - - /** - * delete the connections related with the pageflow node. - * - * @param node - - * the deleting pageflow node - */ - private void deleteConnections(PageflowNode node) { - while (node.getOutlinks().size() > 0) { - // Note:should save the source and target of the link, otherwise - // source and target will be lost, - // when the source and target node remove the link. - PageflowLink link = (PageflowLink) node.getOutlinks().get(0); - sourceConnections.add(link); - sourceConnectionSources.add(link.getSource()); - sourceConnectionTargets.add(link.getTarget()); - - link.getTarget().getInlinks().remove(link); - node.getOutlinks().remove(link); - parent.getLinks().remove(link); - } - - while (node.getInlinks().size() > 0) { - // Note: should save the source and target of the link, otherwise - // source and target will be lost, - // when the source and target node remove the link. - PageflowLink link = (PageflowLink) node.getInlinks().get(0); - targetConnections.add(link); - targetConnectionSources.add(link.getSource()); - targetConnectionTargets.add(link.getTarget()); - - link.getSource().getOutlinks().remove(link); - node.getInlinks().remove(link); - parent.getLinks().remove(link); - } - } - - /** - * execute the delete command - * - * - */ - protected void primExecute() { - deleteConnections(child); - index = parent.getNodes().indexOf(child); - parent.getNodes().remove(child); - } - - /** - * restore the connections of the deleted pageflow node - * - * @param node - - * the deleted pageflow node - */ - private void restoreConnections(PageflowNode node) { - for (int i = 0; i < sourceConnections.size(); i++) { - // restore the link with the source and target - PageflowLink link = (PageflowLink) sourceConnections.get(i); - PageflowNode source = (PageflowNode) sourceConnectionSources.get(i); - PageflowNode target = (PageflowNode) sourceConnectionTargets.get(i); - link.setSource(source); - link.setTarget(target); - - parent.getLinks().add(link); - node.getOutlinks().add(link); - link.getTarget().getInlinks().add(link); - } - sourceConnections.clear(); - for (int i = 0; i < targetConnections.size(); i++) { - // restore the link with the source and target - PageflowLink link = (PageflowLink) targetConnections.get(i); - PageflowNode source = (PageflowNode) targetConnectionSources.get(i); - PageflowNode target = (PageflowNode) targetConnectionTargets.get(i); - link.setSource(source); - link.setTarget(target); - - parent.getLinks().add(link); - node.getInlinks().add(link); - link.getSource().getOutlinks().add(link); - } - targetConnections.clear(); - } - - /** - * set the child pageflow node - * - * @param c - - * the child pageflow node - */ - public void setChild(PageflowNode c) { - child = c; - } - - /** - * set the parent pageflow - * - * @param p - - * the parent pageflow - */ - public void setParent(Pageflow p) { - parent = p; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/EMFCommandGEFAdapter.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/EMFCommandGEFAdapter.java deleted file mode 100644 index 7e23cf251..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/EMFCommandGEFAdapter.java +++ /dev/null @@ -1,124 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.command; - -import org.eclipse.gef.commands.Command; - -/** - * This class is used to adapter EMF Command to GEF Command. - * - * @author xgzhang - * @version - */ -public class EMFCommandGEFAdapter extends Command { - private org.eclipse.emf.common.command.Command emfCommand; - - /** - * - */ - public EMFCommandGEFAdapter( - org.eclipse.emf.common.command.Command emfCommand) { - super(); - this.emfCommand = emfCommand; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.commands.Command#canExecute() - */ - public boolean canExecute() { - if (emfCommand == null) { - return false; - } - return emfCommand.canExecute(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.commands.Command#canUndo() - */ - public boolean canUndo() { - if (emfCommand == null) { - return false; - } - return emfCommand.canUndo(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.commands.Command#dispose() - */ - public void dispose() { - if (emfCommand == null) { - return; - } - emfCommand.dispose(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.commands.Command#execute() - */ - public void execute() { - if (emfCommand == null) { - return; - } - emfCommand.execute(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.commands.Command#getLabel() - */ - public String getLabel() { - if (emfCommand == null) { - return null; - } - return emfCommand.getLabel(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.commands.Command#redo() - */ - public void redo() { - if (emfCommand == null) { - return; - } - emfCommand.redo(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.commands.Command#undo() - */ - public void undo() { - if (emfCommand == null) { - return; - } - emfCommand.undo(); - } - - /** - * - */ - public org.eclipse.emf.common.command.Command getEMFCommand() { - return emfCommand; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/EMFCommandStackGEFAdapter.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/EMFCommandStackGEFAdapter.java deleted file mode 100644 index a22e62a19..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/EMFCommandStackGEFAdapter.java +++ /dev/null @@ -1,179 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.command; - -import java.util.EventObject; - -import org.eclipse.emf.common.command.CommandStackListener; -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.commands.CommandStack; - -/** - * This adapter is used to let editor be able to monitor EMF CommandStack, e.g., - * in StructuredTextEditor, using GEF CommandStack. - * - * @author xgzhang - * @version - */ -public class EMFCommandStackGEFAdapter extends CommandStack implements - CommandStackListener { - private org.eclipse.emf.common.command.BasicCommandStack emfCommandStack; - - /** - * - */ - public EMFCommandStackGEFAdapter( - org.eclipse.emf.common.command.BasicCommandStack emfCommandStack) { - super(); - this.emfCommandStack = emfCommandStack; - this.emfCommandStack.addCommandStackListener(this); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.commands.CommandStack#canRedo() - */ - public boolean canRedo() { - if (emfCommandStack == null) { - return false; - } - return emfCommandStack.canRedo(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.commands.CommandStack#canUndo() - */ - public boolean canUndo() { - if (emfCommandStack == null) { - return false; - } - return emfCommandStack.canUndo(); - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.commands.CommandStack#execute(org.eclipse.gef.commands.Command) - */ - public void execute(Command command) { - if (!(command instanceof EMFCommandGEFAdapter)) { - return; - } - - org.eclipse.emf.common.command.Command emfCommand = ((EMFCommandGEFAdapter) command) - .getEMFCommand(); - if (emfCommand != null) { - emfCommandStack.execute(emfCommand); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.commands.CommandStack#flush() - */ - public void flush() { - if (emfCommandStack == null) { - return; - } - emfCommandStack.flush(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.commands.CommandStack#getRedoCommand() - */ - public Command getRedoCommand() { - if (emfCommandStack == null || emfCommandStack.getRedoCommand() == null) { - return null; - } - - return new EMFCommandGEFAdapter(emfCommandStack.getRedoCommand()); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.commands.CommandStack#getUndoCommand() - */ - public Command getUndoCommand() { - if (emfCommandStack == null || emfCommandStack.getUndoCommand() == null) { - return null; - } - - return new EMFCommandGEFAdapter(emfCommandStack.getUndoCommand()); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.commands.CommandStack#isDirty() - */ - public boolean isDirty() { - if (emfCommandStack == null) { - return false; - } - return emfCommandStack.isSaveNeeded(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.commands.CommandStack#markSaveLocation() - */ - public void markSaveLocation() { - if (emfCommandStack == null) { - return; - } - emfCommandStack.saveIsDone(); - super.markSaveLocation(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.commands.CommandStack#redo() - */ - public void redo() { - if (emfCommandStack == null) { - return; - } - emfCommandStack.redo(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.commands.CommandStack#undo() - */ - public void undo() { - if (emfCommandStack == null) { - return; - } - emfCommandStack.undo(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.emf.common.command.CommandStackListener#commandStackChanged(java.util.EventObject) - */ - public void commandStackChanged(EventObject event) { - this.notifyListeners(); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/IPreExecuteCommand.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/IPreExecuteCommand.java deleted file mode 100644 index f20f2ae1e..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/IPreExecuteCommand.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.command; - -/** - * Command with pre execute checking. - * - * @author Xiao-guang Zhang - * - * - */ -public interface IPreExecuteCommand { - /** - * Do something pre-execution of the actual command execution. - * - * @return - successful to do the pre-execution - */ - boolean preExecute(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/MoveBendpointCommand.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/MoveBendpointCommand.java deleted file mode 100644 index a2468c9dd..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/MoveBendpointCommand.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.command; - -import java.util.Map; - -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowMessages; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowFactory; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage; - -/** - * Move bend point command - */ -public class MoveBendpointCommand extends BendpointCommand { - /** - * old bend point of the link - */ - private PageflowLinkBendpoint oldBendpoint; - - public MoveBendpointCommand() { - // Pageflow.Commands.MoveBendpointCommand.Label = Move Bendpoint - super(PageflowMessages.Pageflow_Commands_MoveBendpointCommand_Label); - } - - /* - * (non-Javadoc) - * - * @see Command#execute() - */ - public void execute() { - Map registry = EPackage.Registry.INSTANCE; - String pageflowURI = PageflowPackage.eNS_URI; - PageflowPackage pageflowPackage = (PageflowPackage) registry - .get(pageflowURI); - PageflowFactory factory = pageflowPackage.getPageflowFactory(); - PageflowLinkBendpoint _newBendpoint = factory.createPFLinkBendpoint(); - - _newBendpoint.setRelativeDimensions(getFirstRelativeDimension(), - getSecondRelativeDimension()); - setOldBendpoint((PageflowLinkBendpoint) getPFLink().getBendPoints().get( - getIndex())); - - getPFLink().setBendpoint(getIndex(), _newBendpoint); - super.execute(); - } - - /** - * get the old bend point - * - * @return - old bend point - */ - protected PageflowLinkBendpoint getOldBendpoint() { - return oldBendpoint; - } - - /** - * set the old bend point - * - * @param bp - - * old bend point - */ - public void setOldBendpoint(PageflowLinkBendpoint bp) { - oldBendpoint = bp; - } - - /* - * (non-Javadoc) - * - * @see Command#undo() - */ - public void undo() { - super.undo(); - getPFLink().setBendpoint(getIndex(), getOldBendpoint()); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/OpenEditorCommand.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/OpenEditorCommand.java deleted file mode 100644 index e0940623c..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/OpenEditorCommand.java +++ /dev/null @@ -1,190 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.command; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.Path; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.commands.Command; -import org.eclipse.jst.jsf.common.ui.internal.logging.Logger; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.FacesConfigEditor; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowMessages; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowNodeImpl; -import org.eclipse.jst.jsf.facesconfig.ui.util.WebrootUtil; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IEditorDescriptor; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.ide.IDE; -import org.eclipse.ui.part.FileEditorInput; - -/** - * - * This is the Command for opening a file in its default editor - * - * @author Xiao-guang Zhang - */ -public class OpenEditorCommand extends Command { - /** The selected object */ - private PageflowNodeImpl child = null; - - /** The edit part */ - private EditPart part; - - /** log instance */ - private static final Logger log = EditorPlugin - .getLogger(FacesConfigEditor.class); - - /* - * (non-Javadoc) - * - * @see Command#canExecute() - */ - public boolean canExecute() { - return true; - } - - /** - * The constructor - * - * @param part - - * the EditPart - */ - public OpenEditorCommand(EditPart part) { - // Pageflow.Commands.OpenEditorCommand.Label = Open Editor - super(PageflowMessages.Pageflow_Commands_OpenEditorCommand_Label); - this.part = part; - } - - /** - * Sets the selected object - * - * @param child - - * the PFPageImpl - */ - public void setChild(PageflowNodeImpl child) { - this.child = child; - } - - public PageflowNodeImpl getChild() { - return child; - } - - /** - * open existed JSF file or call the wizard to create a new one. - * - */ - private void executeOpenPFPage() { - IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); - String pagePath = ((PageflowPage) (part.getModel())).getPath(); - - // Check the fileName is empty or not - if (pagePath != null && pagePath.length() > 0) { - String resourceName = WebrootUtil.getProjectPath((EObject) part - .getModel(), pagePath); - Path resourcePath = new Path(resourceName); - if (resourcePath.getFileExtension() != null) { - final IFile file = (IFile) workspaceRoot - .findMember(resourcePath); - openExistingJSFFile(file); - } else { - // Pageflow.PageflowEditor.Alert.errorOpenEditor4JSFTitle = - // Open JSF File Error - // Pageflow.PageflowEditor.Alert.errorOpenEditor4JSFFolderInfo = - // Cannot open the page in the page editor. - EditorPlugin - .getAlerts() - .error( - "Pageflow.PageflowEditor.Alert.errorOpenEditor4JSFTitle", - "Pageflow.PageflowEditor.Alert.errorOpenEditor4JSFFolderInfo"); - } - } else - // if the fileName is empty, a new jsf file should be created! - { - // Pageflow.PageflowEditor.Alert.errorOpenEditor4JSFTitle = Open JSF - // File Error - // Pageflow.PageflowEditor.Alert.confirmCreateNewJSFFile = No jsp - // file is related with this page. - EditorPlugin.getAlerts().error( - "Pageflow.PageflowEditor.Alert.errorOpenEditor4JSFTitle", - "Pageflow.PageflowEditor.Alert.confirmCreateNewJSFFile");// ) - } - } - - /** - * open existing jsf file in a new editor. - * - * @param file - */ - private void openExistingJSFFile(final IFile file) { - // if the file is existed, open it. - if (null != file && file.exists()) { - Display display = PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getShell().getDisplay(); - display.asyncExec(new Runnable() { - public void run() { - IDE.setDefaultEditor(file, null); - try { - IWorkbenchPage page = PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getActivePage(); - IEditorDescriptor desc = IDE.getEditorDescriptor(file); - page.openEditor(new FileEditorInput(file), - desc.getId(), true, IWorkbenchPage.MATCH_INPUT - | IWorkbenchPage.MATCH_ID); - } catch (PartInitException e) { - // Pageflow.PageflowEditor.Error.CanNotOpenEditor4JSF = - // The jsf file can not be opened in the editor. - log - .error( - "Pageflow.PageflowEditor.Error.canNotOpenEditor4JSF", - e); - // Pageflow.PageflowEditor.Alert.errorOpenEditor4JSFTitle - // = Open JSF File Error - EditorPlugin - .getAlerts() - .error( - "Pageflow.PageflowEditor.Alert.errorOpenEditor4JSFTitle", - "Pageflow.PageflowEditor.Error.CanNotOpenEditor4JSF"); - } - } - }); - } else - // otherwise, pop-up a error message box - { - String pagePath = ((PageflowPage) (part.getModel())).getPath(); - // Pageflow.PageflowEditor.Alert.errorOpenEditor4JSFTitle = Open JSF - // File Error - // Pageflow.PageflowEditor.Alert.errorOpenEditor4JSFInfo = The JSF - // file is not existed. - EditorPlugin.getAlerts().error( - "Pageflow.PageflowEditor.Alert.errorOpenEditor4JSFTitle", - "Pageflow.PageflowEditor.Alert.errorOpenEditor4JSFInfo", - pagePath); - } - } - - /** - * Executes the OpenEditorCommand and opens the editor - */ - public void execute() { - if (part.getModel() instanceof PageflowPage) { - executeOpenPFPage(); - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/OrphanChildCommand.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/OrphanChildCommand.java deleted file mode 100644 index 921552d63..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/OrphanChildCommand.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.command; - -import java.util.List; - -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.gef.commands.Command; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowMessages; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode; - -/** - * This is the orphan child command for pageflow container - * - */ -public class OrphanChildCommand extends Command { - - /** old location of pageflow node */ - private Point oldLocation; - - /** the parent pageflow */ - private Pageflow pageflow; - - /** the child pageflow node */ - private PageflowNode child; - - /** the index of pageflow nodes */ - private int index; - - public OrphanChildCommand() { - // Pageflow.Commands.OrphanChildCommand.Label = Orphan Child - super(PageflowMessages.Pageflow_Commands_OrphanChildCommand_Label); - } - - /* - * (non-Javadoc) - * - * @see Command#execute() - */ - public void execute() { - List children = pageflow.getNodes(); - index = children.indexOf(child); - oldLocation = new Point(child.getX(), child.getY()); - pageflow.getNodes().remove(child); - } - - /* - * (non-Javadoc) - * - * @see Command#redo() - */ - public void redo() { - pageflow.getNodes().remove(child); - } - - /* - * (non-Javadoc) - * - * @see Command#undo() - */ - public void undo() { - child.setX(oldLocation.x); - child.setY(oldLocation.y); - pageflow.getNodes().add(index, child); - } - - /** - * set the child pageflow node - * - * @param child - - * child pageflow node - */ - public void setChild(PageflowNode child) { - this.child = child; - } - - /** - * set the parent pageflow - * - * @param parent - - * parent pageflow - */ - public void setParent(Pageflow parent) { - pageflow = parent; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/PreExecuteCommandStack.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/PreExecuteCommandStack.java deleted file mode 100644 index 2741862d8..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/PreExecuteCommandStack.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.command; - -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.commands.CommandStack; - -/** - * Before the command stack called execute to do the actual model modification, - * it will call the command's IPreExecuteCommand inteface to check the command - * can be execute or not. - * - * - * @author Xiao-guang Zhang - */ -public class PreExecuteCommandStack extends CommandStack { - /** - * - */ - public PreExecuteCommandStack() { - super(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.commands.CommandStack#execute(org.eclipse.gef.commands.Command) - */ - public void execute(Command command) { - if (command == null || !command.canExecute()) { - return; - } - if (command instanceof IPreExecuteCommand) { - if (!((IPreExecuteCommand) command).preExecute()) { - return; - } - } - super.execute(command); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/ReconnectConnectionCommand.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/ReconnectConnectionCommand.java deleted file mode 100644 index 510357c33..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/ReconnectConnectionCommand.java +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.command; - -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.util.PageflowValidation; - -/** - * Change the end of a link. - * - * @author hmeng - * - */ -public class ReconnectConnectionCommand extends ConnectionCommand { - - public ReconnectConnectionCommand() { - // TODO Auto-generated constructor stub - } - - public boolean canExecute() { - // if user didn't set PFLink object beforehand, this command can't be - // executed. - if (link == null || link.eContainer() == null) { - return false; - } - - // Reconnect both source and target - if (oldSource != null && source != null && oldTarget != null - && target != null) { - if (!PageflowValidation.getInstance().isValidLinkForCreation( - source, target)) { - return false; - } - } - - // Reconnect source - if (oldSource != null && source != null) { - if (!PageflowValidation.getInstance().isValidLinkForCreation( - source, oldTarget)) { - return false; - } - } - // Reconnect target - if (oldTarget != null && target != null) { - if (!PageflowValidation.getInstance().isValidLinkForCreation( - oldSource, target)) { - return false; - } - } - - return true; - - } - - public void doExecute() { - String outcome = null, action = null, largeIcon = null, smallIcon = null; - boolean isRedirect = false; - outcome = link.getOutcome(); - action = link.getFromaction(); - isRedirect = link.isRedirect(); - largeIcon = link.getLargeicon(); - smallIcon = link.getSmallicon(); - // It is a reconnect source command - if (oldSource != null && source != null) { - link.setSource(source); - } - // It is a reconnect target command - if (oldTarget != null && target != null) { - link.setTarget(target); - } - link.setOutcome(outcome); - link.setFromaction(action); - link.setLargeicon(largeIcon); - link.setSmallicon(smallIcon); - link.setRedirect(isRedirect); - } - - public void undo() { - if (canExecute()) { - // It was a reconnect source command - if (oldSource != null && source != null) { - // The link source must be replaced by the oldSource - if (link.getSource() != null) { - link.getSource().getOutlinks().remove(link); - } - source.getOutlinks().remove(link); - link.setSource(oldSource); - } - // It was a reconnect target command - if (oldTarget != null && target != null) { - // The link target must be replaced by the oldTarget - if (link.getTarget() != null) { - link.getTarget().getInlinks().remove(link); - } - target.getInlinks().remove(link); - link.setTarget(oldTarget); - } - } - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/RenameNodeCommand.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/RenameNodeCommand.java deleted file mode 100644 index e3e526920..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/RenameNodeCommand.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.command; - -import org.eclipse.gef.commands.Command; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode; - -/** - * Command to rename Node. - * - * @author xgzhang - */ -public class RenameNodeCommand extends Command { - - /** new pageflow node */ - private PageflowNode node; - - /** new node name */ - private String name; - - /** old node name */ - private String oldName; - - /** - * @see org.eclipse.gef.commands.Command#execute() - */ - public void execute() { - node.setName(name); - } - - /** - * Sets the new Activity name - * - * @param string - * the new name - */ - public void setName(String string) { - name = string; - } - - /** - * Sets the old Activity name - * - * @param string - * the old name - */ - public void setOldName(String string) { - oldName = string; - } - - /** - * Sets the source Activity - * @param node - * the source Activity - */ - public void setSource(PageflowNode node) { - this.node = node; - } - - /** - * @see org.eclipse.gef.commands.Command#undo() - */ - public void undo() { - node.setName(oldName); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/SetConstraintCommand.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/SetConstraintCommand.java deleted file mode 100644 index 1d90a740f..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/command/SetConstraintCommand.java +++ /dev/null @@ -1,136 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.command; - -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.commands.Command; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement; - -/** - * This is the SetConstraint command for XY layout edit policy - * - */ -public class SetConstraintCommand extends Command { - /** location command label */ - private static final String COMMAND_LABEL_LOCATION = "change location command"; - - /** resize command label */ - private static final String COMMAND_LABEL_RESIZE = "resize command"; - - /** new position */ - private Point newPos; - - /** new size */ - private Dimension newSize; - - /** olde position */ - private Point oldPos; - - /** old size */ - private Dimension oldSize; - - /** pageflow element */ - private PageflowElement part; - - /* - * (non-Javadoc) - * - * @see Command#execute() - */ - public void execute() { - oldSize = new Dimension(part.getWidth(), part.getHeight()); - oldPos = new Point(part.getX(), part.getY()); - part.setX(newPos.x); - part.setY(newPos.y); - part.setHeight(newSize.height); - part.setWidth(newSize.width); - } - - /* - * (non-Javadoc) - * - * @see Command#redo() - */ - public void redo() { - part.setX(newPos.x); - part.setY(newPos.y); - part.setHeight(newSize.height); - part.setWidth(newSize.width); - } - - /* - * (non-Javadoc) - * - * @see Command#undo() - */ - public void undo() { - part.setX(oldPos.x); - part.setY(oldPos.y); - part.setHeight(oldSize.height); - part.setWidth(oldSize.width); - } - - /** - * return the label of the constaints - */ - public String getLabel() { - if (oldSize.equals(newSize)) { - return COMMAND_LABEL_LOCATION; - } - return COMMAND_LABEL_RESIZE; - } - - /** - * set the new location using rectangle - * - * @param r - - * new location - */ - public void setLocation(Rectangle r) { - setLocation(r.getLocation()); - setSize(r.getSize()); - } - - /** - * set the new location using point - * - * @param p - - * new location point - */ - public void setLocation(Point p) { - newPos = p; - } - - /** - * set the pageflow element - * - * @param part - - * pageflow element - */ - public void setPart(PageflowElement part) { - this.part = part; - } - - /** - * set the new size - * - * @param p - - * new size - */ - public void setSize(Dimension p) { - newSize = p; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/ConfigurableRootEditPart.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/ConfigurableRootEditPart.java deleted file mode 100644 index 083c65edc..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/ConfigurableRootEditPart.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.SimpleLoweredBorder; -import org.eclipse.gef.editparts.ScalableFreeformRootEditPart; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; - -/** - * This RootEditPart can set its own's background, fourground color, and font. - * All this properties can be changed. - * - * @author Xiao-guang Zhang - * - */ -public class ConfigurableRootEditPart extends ScalableFreeformRootEditPart - implements IFigurePreference { - /** - * - */ - public ConfigurableRootEditPart() { - super(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure() - */ - protected IFigure createFigure() { - IFigure fig = super.createFigure(); - fig.setOpaque(true); - fig.setBorder(new SimpleLoweredBorder()); - return fig; - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.editparts.IFigurePreference#setForegroundColor(org.eclipse.swt.graphics.Color) - */ - public void setForegroundColor(Color c) { - getFigure().setForegroundColor(c); - - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.editparts.IFigurePreference#setBackgroundColor(org.eclipse.swt.graphics.Color) - */ - public void setBackgroundColor(Color c) { - getFigure().setBackgroundColor(c); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.editparts.IFigurePreference#setFont(org.eclipse.swt.graphics.Font) - */ - public void setFont(Font f) { - getFigure().setFont(f); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/DirectEditCellEditorLocator.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/DirectEditCellEditorLocator.java deleted file mode 100644 index 05f234a5a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/DirectEditCellEditorLocator.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart; - -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.tools.CellEditorLocator; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Text; - -/** - * CellEditorLocator for Pageflow Node. - * - * @author - Xiaoguang Zhang - */ -public class DirectEditCellEditorLocator implements CellEditorLocator { - /** the source label */ - private Label label; - - /** - * Creates a new DirectEditCellEditorLocator for the given Label - * - * @param label - * the Label - */ - public DirectEditCellEditorLocator(Label label) { - setLabel(label); - } - - /* - * (non-javadoc) - * - * @see CellEditorLocator#relocate(CellEditor) - */ - public void relocate(CellEditor celleditor) { - Text text = (Text) celleditor.getControl(); - Point pref = text.computeSize(-1, -1); - // get the label's boundary - Rectangle rect = label.getTextBounds().getCopy(); - label.translateToAbsolute(rect); - - // because the label can be empty and the size is too small - // here get the prefered text size according to label's size and default - // size. - int width, height; - if (pref.x > rect.width) { - width = pref.x; - } else { - width = rect.width; - } - - if (pref.y > rect.height) { - height = pref.y; - } else { - height = rect.height; - } - - // set the boundary of the text control - text.setBounds(rect.x - 1, rect.y - 1, width + 1, height + 1); - } - - /** - * Returns the Label figure. - * - * @return the Label - */ - protected Label getLabel() { - return label; - } - - /** - * Sets the label. - * - * @param label - * The label to set - */ - protected void setLabel(Label label) { - this.label = label; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/IAnnotationEditPart.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/IAnnotationEditPart.java deleted file mode 100644 index 2c489f855..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/IAnnotationEditPart.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.text.source.Annotation; - -/** - * Edit part's Annotation interface - * - * @author Xiao-guang Zhang - * - */ -public interface IAnnotationEditPart { - /** - * decorate current Edit Part. - * - */ - void addAnnotation(Annotation annotation); - - /** - * un-decorate current EditPart - * - */ - void removeAnnotation(); - - /** - * get the maker's resource instance. - * - * @return marker resource - */ - IResource getMarkerResource(); - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/IConnectionPreference.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/IConnectionPreference.java deleted file mode 100644 index 8ff1b9a99..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/IConnectionPreference.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart; - -import org.eclipse.swt.graphics.Color; - -/** - * This interface can be used to set Connection's preference - * - * @author Xiaoguang Zhang - * - */ -public interface IConnectionPreference extends IFigurePreference { - - /** - * set the connection line width - * - * @param w - */ - void setLineWidth(int w); - - /** - * set the label visible or not - * - * @param b - */ - void setLabelVisible(boolean b); - - /** - * set the label's foreground color - * - * @param c - */ - void setLabelForegroundColor(Color c); - - /** - * set the label's background color - * - * @param c - */ - void setLabelBackgroundColor(Color c); - - /** - * set the connection router's style, it can be LINE_ROUTING_MANUAL, - * LINE_ROUTING_MANHATTAN - * - * @param style - - * The new connection router's style - */ - void setConnectionRouterStyle(int style); - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/IFigurePreference.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/IFigurePreference.java deleted file mode 100644 index 3dc924b1e..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/IFigurePreference.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart; - -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; - -/** - * This interface can be implemented to set the figure's preferences - * - * @author Xiao-guang Zhang - * - */ -public interface IFigurePreference { - /** - * Sets the foreground color. - * - * @param c - * The new foreground color - */ - void setForegroundColor(Color c); - - /** - * Sets the background color. - * - * @param c - * The new background color - */ - void setBackgroundColor(Color c); - - /** - * sets the new font - * - * @param f - */ - void setFont(Font f); - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/ILayerPanePreference.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/ILayerPanePreference.java deleted file mode 100644 index 7bc5d52fc..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/ILayerPanePreference.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart; - -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.swt.graphics.Color; - -/** - * LayerPane has muliple layers, this interface will be used to set different - * layer's style. - * - * @author Xiao-guang Zhang - * - */ -public interface ILayerPanePreference extends IFigurePreference { - public static int LINE_ROUTING_MANUAL = 0; - - public static int LINE_ROUTING_MANHATTAN = 1; - - /** - * sets the grid to be shown or not - * - * @param bVisible - */ - void setGridVisible(boolean bVisible); - - /** - * sets the grid's dimension - * - * @param d - * The new grid spacing - */ - void setGridSpacing(Dimension d); - - /** - * set the grid's foregoundColor - * - * @param c - - * The new foreground color - */ - void setGridForegroundColor(Color c); - - /** - * set the connection router's style, it can be LINE_ROUTING_MANUAL, - * LINE_ROUTING_MANHATTAN - * - * @param style - - * The new connection router's style - */ - void setConnectionRouterStyle(int style); - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/INodePreference.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/INodePreference.java deleted file mode 100644 index 3a2a3f938..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/INodePreference.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart; - - -/** - * This interface can be used to set NodeEditPart's preference - * - * @author Xiaoguang Zhang - * - */ - -public interface INodePreference extends IFigurePreference { - - /** - * Sets the text placement of the label relative to its icon. The default is - * {@link org.eclipse.draw2d.PositionConstants#EAST}. Other possible values are - * {@link org.eclipse.draw2d.PositionConstants#NORTH}, {@link org.eclipse.draw2d.PositionConstants#SOUTH} and - * {@link org.eclipse.draw2d.PositionConstants#WEST}. - * - * @param where - * the text placement - */ - void setTextPlacement(int where); - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PFValidator.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PFValidator.java deleted file mode 100644 index fa9422694..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PFValidator.java +++ /dev/null @@ -1,20 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart; - -/** - * @author hmeng - */ - -public interface PFValidator { - void validate(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowContainerEditPart.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowContainerEditPart.java deleted file mode 100644 index 18337a4d3..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowContainerEditPart.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.gef.EditPolicy; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpolicy.PageflowContainerEditPolicy; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpolicy.PageflowXYLayoutEditPolicy; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.synchronization.PFBatchAdapter; - -/** - * abstract class for pageflow container. - */ -abstract public class PageflowContainerEditPart extends PageflowElementEditPart { - - /** - * @param element - - * pageflow model. - */ - public PageflowContainerEditPart(PageflowElement element) { - super(element); - } - - /* - * (non-Javadoc) - * - * @see AbstractGraphicalEditPart#createFigure() - */ - protected IFigure createFigure() { - return null; - } - - /* - * (non-Javadoc) - * - * @see AbstractEditPart#createEditPolicies() - */ - protected void createEditPolicies() { - installEditPolicy(EditPolicy.CONTAINER_ROLE, - new PageflowContainerEditPolicy()); - installEditPolicy(EditPolicy.LAYOUT_ROLE, - new PageflowXYLayoutEditPolicy()); - } - - public Adapter createEMFAdapter() { - return new PFBatchAdapter() { - /* - * (non-Javadoc) - * - * @see PageflowElementEditPart#notifyChanged(Notification) - */ - public void doNotifyChanged(Notification notification) { - int type = notification.getEventType(); - - switch (type) { - case Notification.ADD: - case Notification.ADD_MANY: - case Notification.REMOVE: - case Notification.REMOVE_MANY: - refreshChildren(); - break; - case Notification.SET: - refreshVisuals(); - break; - } - super.notifyChanged(notification); - } - }; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowDirectEditManager.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowDirectEditManager.java deleted file mode 100644 index 769866627..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowDirectEditManager.java +++ /dev/null @@ -1,137 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.gef.tools.CellEditorLocator; -import org.eclipse.gef.tools.DirectEditManager; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.VerifyEvent; -import org.eclipse.swt.events.VerifyListener; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Text; - -/** - * DirectEditManager for Pageflow node - * - * @author - Xiaoguang Zhang - */ -public class PageflowDirectEditManager extends DirectEditManager { - /** text font */ - protected Font scaledFont; - - /** verify listener for the text control */ - protected VerifyListener verifyListener; - - /** the direct editor's parent label. */ - protected Label label; - - /** - * Creates a new PageflowDirectEditManager with the given attributes. - * - * @param source - * the source EditPart - * @param editorType - * type of editor - * @param locator - * the CellEditorLocator - */ - public PageflowDirectEditManager(GraphicalEditPart source, - Class editorType, CellEditorLocator locator, Label label) { - super(source, editorType, locator); - this.label = label; - } - - /* - * (non-javadoc) - * - * @see org.eclipse.gef.tools.DirectEditManager#bringDown() - */ - protected void bringDown() { - // This method might be re-entered when super.bringDown() is called. - Font disposeFont = scaledFont; - scaledFont = null; - super.bringDown(); - if (disposeFont != null && !disposeFont.isDisposed()) { - disposeFont.dispose(); - } - } - - /* - * (non-javadoc) - * - * @see org.eclipse.gef.tools.DirectEditManager#initCellEditor() - */ - protected void initCellEditor() { - Text text = (Text) getCellEditor().getControl(); - verifyListener = new VerifyListener() { - public void verifyText(VerifyEvent event) { - Text text_ = (Text) getCellEditor().getControl(); - String oldText = text_.getText(); - // get the left string of the new input character - String leftText = oldText.substring(0, event.start); - // get the right string of the new input charactor - String rightText = oldText.substring(event.end, oldText - .length()); - - GC gc = new GC(text_); - Point size = gc.textExtent(leftText + event.text + rightText); - gc.dispose(); - if (size.x != 0) { - size = text_.computeSize(size.x, SWT.DEFAULT); - } - getCellEditor().getControl().setSize(size.x, size.y); - } - }; - text.addVerifyListener(verifyListener); - - // set the initial text, font, to the direct editor - String initialLabelText = label.getText(); - getCellEditor().setValue(initialLabelText); - IFigure figure = getEditPart().getFigure(); - final Font figureFont = figure.getFont(); - // take a copy of the font data for the label we are cell editing - FontData data = figureFont.getFontData()[0]; - Dimension fontSize = new Dimension(0, data.getHeight()); - label.translateToAbsolute(fontSize); - data.setHeight(fontSize.height); - - if (scaledFont != null && !scaledFont.isDisposed()) - { - scaledFont.dispose(); - } - scaledFont = new Font(figureFont.getDevice(), data); - - text.setFont(scaledFont); - text.selectAll(); - } - - /* - * (non-javadoc) - * - * @see org.eclipse.gef.tools.DirectEditManager#unhookListeners() - */ - protected void unhookListeners() { - super.unhookListeners(); - Text text = (Text) getCellEditor().getControl(); - text.removeVerifyListener(verifyListener); - verifyListener = null; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowEditPart.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowEditPart.java deleted file mode 100644 index 0ff56f2e9..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowEditPart.java +++ /dev/null @@ -1,387 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -import org.eclipse.draw2d.BendpointConnectionRouter; -import org.eclipse.draw2d.ConnectionLayer; -import org.eclipse.draw2d.FanRouter; -import org.eclipse.draw2d.FreeformLayer; -import org.eclipse.draw2d.FreeformLayout; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.ManhattanConnectionRouter; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.util.TreeIterator; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gef.CompoundSnapToHelper; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.LayerConstants; -import org.eclipse.gef.SnapToGeometry; -import org.eclipse.gef.SnapToGrid; -import org.eclipse.gef.SnapToGuides; -import org.eclipse.gef.SnapToHelper; -import org.eclipse.gef.editparts.AbstractEditPart; -import org.eclipse.gef.editparts.GridLayer; -import org.eclipse.gef.editpolicies.RootComponentEditPolicy; -import org.eclipse.gef.editpolicies.SnapFeedbackPolicy; -import org.eclipse.gef.rulers.RulerProvider; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.text.source.Annotation; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.synchronization.FC2PFTransformer; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.synchronization.PFBatchAdapter; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.util.PageflowAnnotationUtil; -import org.eclipse.jst.jsf.facesconfig.ui.preference.GEMPreferences; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; - -/** - * The container editr part for the whole pageflow, which uses the - * WindowFigure(GEM) as the container figure. - * - */ -public class PageflowEditPart extends PageflowContainerEditPart implements - LayerConstants, ILayerPanePreference { - /** The seperation for the two possible coincided connections */ - private static final int CONNECTION_SEPERATION = 20; - - private int connectionStyle = -1; - - /** - * Creates a new PageflowEditPart instance. - * - * @param pageflow - - * pageflow model - */ - protected PageflowEditPart(Pageflow pageflow) { - super(pageflow); - } - - /* - * (non-Javadoc) - * - * @see AbstractGraphicalEditPart#createFigure() - */ - protected IFigure createFigure() { - FreeformLayer layer = new FreeformLayer(); - // layer.setOpaque(true); - layer.setLayoutManager(new FreeformLayout()); - return layer; - } - - /* - * (non-Javadoc) - * - * @see AbstractEditPart#createEditPolicies() - */ - protected void createEditPolicies() { - super.createEditPolicies(); - - installEditPolicy(EditPolicy.NODE_ROLE, null); - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, null); - // installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, null); - installEditPolicy(EditPolicy.COMPONENT_ROLE, - new RootComponentEditPolicy()); - installEditPolicy("Snap Feedback", new SnapFeedbackPolicy()); //$NON-NLS-1$ - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) - */ - public Object getAdapter(Class key) { - if (key == SnapToHelper.class) { - IPreferenceStore store = EditorPlugin.getDefault() - .getPreferenceStore(); - - List snapStrategies = new ArrayList(); - Boolean bRulerVisible = (Boolean) getViewer().getProperty( - RulerProvider.PROPERTY_RULER_VISIBILITY); - if (bRulerVisible != null && bRulerVisible.booleanValue()) { - snapStrategies.add(new SnapToGuides(this)); - } - - boolean bSnapToGeometry = store - .getBoolean(GEMPreferences.SNAP_TO_GEOMETRY); - if (bSnapToGeometry) { - snapStrategies.add(new SnapToGeometry(this)); - } - boolean bSnapToGrid = store.getBoolean(GEMPreferences.SNAP_TO_GRID); - if (bSnapToGrid) { - snapStrategies.add(new SnapToGrid(this)); - } - - if (snapStrategies.size() == 0) { - return null; - } - if (snapStrategies.size() == 1) { - return snapStrategies.get(0); - } - - SnapToHelper ss[] = new SnapToHelper[snapStrategies.size()]; - for (int i = 0; i < snapStrategies.size(); i++) { - ss[i] = (SnapToHelper) snapStrategies.get(i); - } - return new CompoundSnapToHelper(ss); - } - return super.getAdapter(key); - } - - /** - * Returns the Pageflow. - * - * @return the pageflow - */ - public Pageflow getPageflow() { - return (Pageflow) getPageflowElement(); - } - - /* - * (non-Javadoc) - * - * @see AbstractEditPart#getModelChildren() - */ - protected List getModelChildren() { - List allChildren = new LinkedList(); - Iterator it; - - it = getPageflow().getNodes().iterator(); - while (it.hasNext()) { - allChildren.add(it.next()); - } - - return allChildren; - } - - public Adapter createEMFAdapter() { - return new PFBatchAdapter() { - /* - * (non-Javadoc) - * - * @see Adapter#notifyChanged(Notification) - */ - public void doNotifyChanged(Notification notification) { - int type = notification.getEventType(); - - // int featureId = notification.getFeatureID( - // PageflowPackage.class ); - switch (type) { - case Notification.ADD: - case Notification.ADD_MANY: - case Notification.REMOVE: - case Notification.REMOVE_MANY: - refreshChildren(); - break; - - case Notification.SET: - refreshChildren(); - refreshVisuals(); - break; - case FC2PFTransformer.MY_NOTIFICATION_TYPE1: - restore((Pageflow) getModel()); - refreshChildren(); - refreshVisuals(); - break; - // restore all children - case FC2PFTransformer.MY_NOTIFICATION_TYPE: - // stop all children - postPone((Pageflow) getModel()); - break; - } - } - - protected void restore(Pageflow pageflow) { - TreeIterator nodes; - // restore - nodes = pageflow.eAllContents(); - while (nodes.hasNext()) { - setPostpone((EObject) nodes.next(), false); - } - setPostpone(pageflow, false); - } - - void setPostpone(EObject node, boolean enable) { - List adapters = node.eAdapters(); - for (int i = 0; i < adapters.size(); i++) { - if (adapters.get(i) instanceof PFBatchAdapter) { - ((PFBatchAdapter) adapters.get(i)) - .setNeedPostpone(enable); - } - } - } - - protected void postPone(Pageflow pageflow) { - TreeIterator nodes; - // postpone - nodes = pageflow.eAllContents(); - while (nodes.hasNext()) { - setPostpone((EObject) nodes.next(), true); - } - setPostpone(pageflow, true); - } - - }; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.editparts.AbstractEditPart#refreshVisuals() - */ - protected void refreshVisuals() { - super.refreshVisuals(); - for (int i = 0; i < this.getChildren().size(); i++) { - ((AbstractEditPart) getChildren().get(i)).refresh(); - } - ConnectionLayer cLayer = (ConnectionLayer) getLayer(CONNECTION_LAYER); - - if (cLayer.getConnectionRouter() == null) { - setConnectionRouterStyle(getConnectionRouterStyle()); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.editparts.AbstractEditPart#refreshChildren() - */ - protected void refreshChildren() { - super.refreshChildren(); - PageflowAnnotationUtil.validatePageflow(this); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.editparts.IFigurePreference#setFont(org.eclipse.swt.graphics.Font) - */ - public void setFont(Font f) { - getFigure().setFont(f); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.editparts.ILayerPanePreference#setConnectionRouterStyle(int) - */ - public void setConnectionRouterStyle(int style) { - connectionStyle = style; - ConnectionLayer cLayer = (ConnectionLayer) getLayer(CONNECTION_LAYER); - if (style == ILayerPanePreference.LINE_ROUTING_MANHATTAN) { - FanRouter router = new FanRouter(); - router.setSeparation(CONNECTION_SEPERATION); - router.setNextRouter(new ManhattanConnectionRouter()); - cLayer.setConnectionRouter(router); - } else if (style == ILayerPanePreference.LINE_ROUTING_MANUAL) { - FanRouter router = new FanRouter(); - router.setSeparation(CONNECTION_SEPERATION); - router.setNextRouter(new BendpointConnectionRouter()); - cLayer.setConnectionRouter(router); - } - } - - /** - * get the foreground color from preference - * @return the router style value - * - */ - public int getConnectionRouterStyle() { - if (this.connectionStyle == -1) { - IPreferenceStore store = EditorPlugin.getDefault() - .getPreferenceStore(); - String connectionStyle_ = store - .getString(GEMPreferences.LINE_ROUTING); - - if (GEMPreferences.LINE_ROUTING_MANHATTAN.equals(connectionStyle_)) { - this.connectionStyle = ILayerPanePreference.LINE_ROUTING_MANHATTAN; - } else { - this.connectionStyle = ILayerPanePreference.LINE_ROUTING_MANUAL; - } - } - return this.connectionStyle; - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.editparts.IFigurePreference#setForegroundColor(org.eclipse.swt.graphics.Color) - */ - public void setForegroundColor(Color c) { - getFigure().setForegroundColor(c); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.editparts.IFigurePreference#setBackgroundColor(org.eclipse.swt.graphics.Color) - */ - public void setBackgroundColor(Color c) { - // getLayer(PRIMARY_LAYER).setOpaque(true); - getLayer(PRIMARY_LAYER).setBackgroundColor(c); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.editparts.IFigurePreference#setGridVisible(boolean) - */ - public void setGridVisible(boolean bVisible) { - GridLayer gl = (GridLayer) getLayer(GRID_LAYER); - gl.setVisible(bVisible); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.editparts.IFigurePreference#setGridSpacing(org.eclipse.draw2d.geometry.Dimension) - */ - public void setGridSpacing(Dimension d) { - GridLayer gl = (GridLayer) getLayer(GRID_LAYER); - gl.setSpacing(d); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.editparts.ILayerPanePreference#setGridForegroundColor(org.eclipse.swt.graphics.Color) - */ - public void setGridForegroundColor(Color c) { - GridLayer gl = (GridLayer) getLayer(GRID_LAYER); - gl.setForegroundColor(c); - } - - protected void performDirectEdit() { - // do nothing - } - - protected void performOpen() { - // do nothing - } - - public void addAnnotation(Annotation annotation) { - // do nothing - - } - - public void removeAnnotation() { - // do nothing - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowEditPartsFactory.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowEditPartsFactory.java deleted file mode 100644 index fe5723589..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowEditPartsFactory.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart; - -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPartFactory; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode; - -/** - * - * Edit part factory to create different pageflow elements. - * - * - */ -public class PageflowEditPartsFactory implements EditPartFactory { - /* - * (non-Javadoc) - * - * @see EditPartFactory#createEditPart(EditPart, Object) - */ - public EditPart createEditPart(EditPart context, Object obj) { - if (obj instanceof Pageflow) { - return new PageflowEditPart((Pageflow) obj); - } else if (obj instanceof PageflowNode) { - return new PageflowNodeEditPart((PageflowNode) obj); - } else if (obj instanceof PageflowLink) { - return new PageflowLinkEditPart((PageflowLink) obj); - } - return null; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowElementEditPart.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowElementEditPart.java deleted file mode 100644 index a3e32ff90..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowElementEditPart.java +++ /dev/null @@ -1,340 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart; - -import org.eclipse.core.resources.IResource; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.gef.Request; -import org.eclipse.gef.RequestConstants; -import org.eclipse.gef.editparts.AbstractGraphicalEditPart; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.text.source.Annotation; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.figure.PageflowNodeFigure; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.PageflowElementPropertySource; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.synchronization.PFBatchAdapter; -import org.eclipse.jst.jsf.facesconfig.ui.util.WebrootUtil; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.views.properties.IPropertySource; - -/** - * - * - * <code>PageflowElementEditPart</code> is the base class for all the - * EditParts in the application, whose model is a subclass of PageflowElement. - * This class maintains the figure's size and location inresponse to changes in - * the model, and registers as a listener on its model using the - * <code>org.eclipse.emf.common.notify.Adapter</code> interface - */ -public abstract class PageflowElementEditPart extends AbstractGraphicalEditPart - implements IAnnotationEditPart { - /** image description for different edit part */ - public static final ImageDescriptor IMG_ACTION = EditorPlugin.getDefault() - .getImageDescriptor("facesconfig/Pageflow_Action16.gif"); //$NON-NLS-1$ - - protected Adapter adapter; - - public Adapter createEMFAdapter() { - return new PFBatchAdapter() { - /* - * (non-Javadoc) - * - * @see AbstractGraphicalEditPart#notifyChanged() - */ - public void doNotifyChanged(Notification notification) { - int type = notification.getEventType(); - int featureId = notification - .getFeatureID(PageflowPackage.class); - if (type == Notification.SET) { - switch (featureId) { - case PageflowPackage.PAGEFLOW_ELEMENT__X: - case PageflowPackage.PAGEFLOW_ELEMENT__Y: - case PageflowPackage.PAGEFLOW_ELEMENT__WIDTH: - case PageflowPackage.PAGEFLOW_ELEMENT__HEIGHT: - refreshVisuals(); - break; - } - } - } - }; - } - - public static final ImageDescriptor IMG_PAGE = EditorPlugin.getDefault() - .getImageDescriptor("facesconfig/Pageflow_Page.gif"); //$NON-NLS-1$ - - public static final ImageDescriptor IMG_NODE = EditorPlugin.getDefault() - .getImageDescriptor("facesconfig/FacesConfig_Pageflow16.gif"); //$NON-NLS-1$ - - /** property source of the pageflow element */ - private IPropertySource propertySource = null; - - private Image image = null; - - protected PageflowElementEditPart(PageflowElement element) { - setModel(element); - } - - /** - * Returns the image for the pageflow element. - * - * @param element - - * pageflow element - * @return - the image for the pageflow element. - */ - public Image getImage(PageflowElement element) { - if (image == null) { - ImageDescriptor imageDescriptor = null; - - if (element instanceof PageflowPage) { - imageDescriptor = IMG_PAGE; - } else { - imageDescriptor = IMG_NODE; - } - - image = EditorPlugin.getDefault().getImageRegistry().get( - imageDescriptor.toString()); - if (null == image) { - EditorPlugin.getDefault().getImageRegistry().put( - imageDescriptor.toString(), imageDescriptor); - image = EditorPlugin.getDefault().getImageRegistry().get( - imageDescriptor.toString()); - } - } - - return image; - } - - /** - * get the type name of the pageflow element - * - * @param element - - * pageflow element - * @return - the type name of the pageflow element - */ - public static String getTypeName(PageflowElement element) { - if (element instanceof Pageflow) { - return "Pageflow"; //$NON-NLS-1$ - } else if (element instanceof PageflowPage) { - return "Page"; //$NON-NLS-1$ - } - - return "[unknown]"; //$NON-NLS-1$ - } - - /* - * (non-Javadoc) - * - * @see AbstractGraphicalEditPart#activate() - */ - public void activate() { - if (isActive()) { - return; - } - - // start listening for changes in the model - hookIntoPageflowElement(getPageflowElement()); - - super.activate(); - } - - /* - * (non-Javadoc) - * - * @see AbstractGraphicalEditPart#deactivate() - */ - public void deactivate() { - if (!isActive()) { - return; - } - - // stop listening for changes in the model - unhookFromPageflowElement(getPageflowElement()); - - super.deactivate(); - } - - /** - * Returns the model as pageflow element. - * - * @return - pageflow element - */ - public PageflowElement getPageflowElement() { - return (PageflowElement) getModel(); - } - - /* - * (non-Javadoc) - * - * @see AbstractEditPart#refreshVisuals() - */ - protected void refreshVisuals() { - if (getParent() != null) { - Point loc = new Point(getPageflowElement().getX(), - getPageflowElement().getY()); - Dimension size = new Dimension(getPageflowElement().getWidth(), - getPageflowElement().getHeight()); - Rectangle r = new Rectangle(loc, size); - - ((GraphicalEditPart) getParent()).setLayoutConstraint(this, - getFigure(), r); - } - } - - /* - * (non-Javadoc) - * - * @see IAdaptable#getAdapter(Class) - */ - public Object getAdapter(Class key) { - /* - * override the default behavior defined in AbstractEditPart which would - * expect the model to be a property sourced. instead the editpart can - * provide a property source - */ - if (key == IPropertySource.class) { - return getPropertySource(); - } - if (key == Adapter.class) { - if (adapter == null) { - adapter = createEMFAdapter(); - } - return adapter; - } - return super.getAdapter(key); - } - - /* - * (non-Javadoc) - * - * @see PageflowElementEditPart#getPropertySource() - */ - protected IPropertySource getPropertySource() { - if (propertySource == null) { - propertySource = new PageflowElementPropertySource( - getPageflowElement()); - } - return propertySource; - } - - /** - * Registers this edit part as a listener for change notifications to the - * specified pageflow element. - * - * @param element - * the pagelfow element that should be observed for change - * notifications - */ - protected void hookIntoPageflowElement(PageflowElement element) { - if (null != element) { - if (!element.eAdapters().contains(getAdapter(Adapter.class))) { - element.eAdapters().add((Adapter) getAdapter(Adapter.class)); - } - } - } - - /** - * Removes this edit part from the specified pageflow element. Thus, it will - * no longe receive change notifications. - * - * @param element - * the pagelfow element that should not be observed any more - */ - protected void unhookFromPageflowElement(PageflowElement element) { - if (null != element) { - element.eAdapters().remove(getAdapter(Adapter.class)); - } - } - - /* - * (non-Javadoc) - * - * @see AbstractGraphicalEditPart#createFigure() - */ - protected IFigure createFigure() { - IFigure figure_ = null; - figure_ = new PageflowNodeFigure(); - PageflowElement elm = getPageflowElement(); - if (elm.getName() != null) { - ((PageflowNodeFigure) figure_).setImageText(getImage(elm), elm - .getName()); - } else { - ((PageflowNodeFigure) figure_).setImageText(getImage(elm), - getTypeName(elm)); - } - ((PageflowNodeFigure) figure_).update(); - return figure_; - } - - /** - * perform corresponding request related with double click or direct edit - * click. - * - * @param request : - * request composed by mouse click. - */ - public void performRequest(Request request) { - // the request is triggered by double clicked on a edit part - if (request.getType() == RequestConstants.REQ_OPEN) { - performOpen(); - } else if (request.getType() == RequestConstants.REQ_DIRECT_EDIT) { - performDirectEdit(); - } - } - - /** - * perfrom direct edit request - * - */ - protected abstract void performDirectEdit(); - - /** - * perform double click request - * - */ - protected abstract void performOpen(); - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.editparts.IEditPartDecorator#decorateEditPart() - */ - public abstract void addAnnotation(Annotation annotation); - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.editparts.IEditPartDecorator#undecorateEditPart() - */ - public abstract void removeAnnotation(); - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.marker.IEditPartMarker#getMarkerResource() - */ - public IResource getMarkerResource() { - IResource resource = WebrootUtil.getResource((EObject) getModel()); - return resource; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowElementTreeEditPart.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowElementTreeEditPart.java deleted file mode 100644 index ca0c32895..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowElementTreeEditPart.java +++ /dev/null @@ -1,251 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.Notifier; -import org.eclipse.gef.editparts.AbstractTreeEditPart; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.PageflowElementPropertySource; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.views.properties.IPropertySource; - -/** - * This is the abstract base <code>TreeEditPart</code> for pageflow elements. - */ -public class PageflowElementTreeEditPart extends AbstractTreeEditPart implements - Adapter { - /** Image descriptor of tree item for the different edit parts */ - public static final ImageDescriptor IMG_PAGE = EditorPlugin.getDefault() - .getImageDescriptor("facesconfig/Pageflow_Page16.gif"); //$NON-NLS-1$ - - public static final ImageDescriptor IMG_NODE = EditorPlugin.getDefault() - .getImageDescriptor("facesconfig/FacesConfig_Pageflow16.gif"); //$NON-NLS-1$ - - /** Property resource for shared property view */ - private IPropertySource propertySource = null; - - /** notifer to pageflow element */ - private Notifier target = null; - - /** - * Returns the image for the pageflow element. - * - * @param element - - * pageflow element, such as Begin, End, Page, and Action. - * @return - the image for the pageflow element - */ - public static Image getImage(PageflowElement element) { - ImageDescriptor imageDescriptor = null; - - if (element instanceof PageflowPage) { - imageDescriptor = IMG_PAGE; - } else { - imageDescriptor = IMG_NODE; - } - - if (null == imageDescriptor) { - return null; - } - - Image image = EditorPlugin.getDefault().getImageRegistry().get( - imageDescriptor.toString()); - if (null == image) { - EditorPlugin.getDefault().getImageRegistry().put( - imageDescriptor.toString(), imageDescriptor); - image = EditorPlugin.getDefault().getImageRegistry().get( - imageDescriptor.toString()); - } - - return image; - } - - /** - * Creates a new PageflowElementTreeEditPart instance. - * - * @param pageflowElement - - * create a new edit part according to the pageflow model - */ - public PageflowElementTreeEditPart(PageflowElement pageflowElement) { - super(pageflowElement); - } - - /* - * (non-Javadoc) - * - * @see IAdaptable#getAdapter(Class) - */ - public Object getAdapter(Class key) { - /* - * override the default behavior defined in AbstractEditPart which would - * expect the model to be a property sourced. instead the editpart can - * provide a property source - */ - if (key == IPropertySource.class) { - return getPropertySource(); - } - return super.getAdapter(key); - } - - /* - * (non-Javadoc) - * - * @see AbstractTreeEditPart#getImage() - */ - protected Image getImage() { - return getImage(getPageflowElement()); - } - - /* - * (non-Javadoc) - * - * @see PageflowElementEditPart#getPropertySource() - */ - protected IPropertySource getPropertySource() { - if (propertySource == null) { - propertySource = new PageflowElementPropertySource( - getPageflowElement()); - } - return propertySource; - } - - /* - * (non-Javadoc) - * - * @see Adapter#getTarget() - */ - public Notifier getTarget() { - return target; - } - - /* - * (non-Javadoc) - * - * @see AbstractTreeEditPart#getText() - */ - protected String getText() { - return (null != getPageflowElement().getName() ? getPageflowElement() - .getName() : "[unnamed]"); //$NON-NLS-1$ - } - - /** - * Returns the model as <code>PageflowElement</code>. - * - * @return - the model as <code>PageflowElement</code> - */ - public PageflowElement getPageflowElement() { - return (PageflowElement) getModel(); - } - - /* - * (non-Javadoc) - * - * @see Adapter#isAdapterForType(Object) - */ - public boolean isAdapterForType(Object type) { - return type.equals(getModel().getClass()); - } - - /* - * (non-Javadoc) - * - * @see Adapter#notifyChanged(Notification) - */ - public void notifyChanged(Notification notification) { - int type = notification.getEventType(); - - switch (type) { - case Notification.ADD: - case Notification.ADD_MANY: - case Notification.REMOVE: - case Notification.REMOVE_MANY: - refreshChildren(); - break; - - case Notification.SET: - refreshVisuals(); - break; - } - } - - /* - * (non-Javadoc) - * - * @see Adapter#setTarget(Notifier) - */ - public void setTarget(Notifier newTarget) { - target = newTarget; - } - - /* - * (non-Javadoc) - * - * @see AbstractGraphicalEditPart#activate() - */ - public void activate() { - if (isActive()) - return; - - // start listening for changes in the model - hookIntoPageflowElement(getPageflowElement()); - - super.activate(); - } - - /* - * (non-Javadoc) - * - * @see AbstractGraphicalEditPart#deactivate() - */ - public void deactivate() { - if (!isActive()) - return; - - // stop listening for changes in the model - unhookFromPageflowElement(getPageflowElement()); - - super.deactivate(); - } - - /** - * Registers this edit part as a listener for change notifications to the - * specified pageflow element. - * - * @param element - - * the pagelfow element that should be observed for change - * notifications - */ - protected void hookIntoPageflowElement(PageflowElement element) { - if (null != element) { - element.eAdapters().add(this); - } - } - - /** - * Removes this edit part from the specified pageflow element. Thus, it will - * no longe receive change notifications. - * - * @param element - * -the pagelfow element that should not be observed - */ - protected void unhookFromPageflowElement(PageflowElement element) { - if (null != element) { - element.eAdapters().remove(this); - } - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowLinkEditPart.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowLinkEditPart.java deleted file mode 100644 index 15eb0fb02..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowLinkEditPart.java +++ /dev/null @@ -1,476 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IResource; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.RelativeBendpoint; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.Notifier; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.editparts.AbstractConnectionEditPart; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.text.source.Annotation; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowMessages; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpolicy.PFLinkBendpointEditPolicy; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpolicy.PFLinkEditPolicy; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpolicy.PFLinkEndpointEditPolicy; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.figure.PFLinkFigure; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.PageflowLinkPropertySource; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.synchronization.PFBatchAdapter; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.util.PageflowAnnotationUtil; -import org.eclipse.jst.jsf.facesconfig.ui.preference.GEMPreferences; -import org.eclipse.jst.jsf.facesconfig.ui.util.WebrootUtil; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.views.properties.IPropertySource; - -/** - * <code>PFLinkEditPart</code> is the EditPart for PFLink model elements. The - * figure for this EditPart is simply a PolylineConnection. Because both - * AbstractConnectionEditPart and the Adapter interface have a getTarget method, - * we use an inner class to implement the Adapter interface in order to work - * around the name collision. - * - * - */ -public class PageflowLinkEditPart extends AbstractConnectionEditPart implements - IConnectionPreference, IAnnotationEditPart, PFValidator { - /** adapter for notification */ - private PFLinkAdapter adapter = new PFLinkAdapter(); - - /** property source of the pflink */ - private IPropertySource propertySource = null; - - /** image description for different edit part */ - public static final ImageDescriptor IMG_WARNING = EditorPlugin.getDefault() - .getImageDescriptor("facesconfig/Pageflow_Quickfix_Error.gif"); - - private int connectionStyle = -1; - - private PFLinkBendpointEditPolicy bendpointEditPolicy; - - /** - * @param element - */ - public PageflowLinkEditPart(PageflowLink element) { - super(); - // element.getPageflow() - setModel(element); - } - - /* - * (non-Javadoc) - * - * @see AbstractGraphicalEditPart#createFigure() - */ - protected IFigure createFigure() { - IFigure figure_ = new PFLinkFigure(); - return figure_; - - } - - /* - * (non-Javadoc) - * - * @see AbstractEditPart#createEditPolicies() - */ - protected void createEditPolicies() { - installEditPolicy(EditPolicy.CONNECTION_ENDPOINTS_ROLE, - new PFLinkEndpointEditPolicy()); - - if (getConnectionRouterStyle() == ILayerPanePreference.LINE_ROUTING_MANUAL) { - installEditPolicy(EditPolicy.CONNECTION_BENDPOINTS_ROLE, - getBendpointEditPolicy()); - } - //PFLinkEditPolicy policy = new PFLinkEditPolicy(); - // policy.setSseModel(model); - installEditPolicy(EditPolicy.CONNECTION_ROLE, new PFLinkEditPolicy()); - - } - - private PFLinkBendpointEditPolicy getBendpointEditPolicy() { - if (bendpointEditPolicy == null) { - bendpointEditPolicy = new PFLinkBendpointEditPolicy(); - } - return bendpointEditPolicy; - } - - public PageflowLink getPFLink() { - return (PageflowLink) getModel(); - } - - private class PFLinkAdapter extends PFBatchAdapter { - private Notifier _newTarget = null; - - // private IPropertySource _propertySource = null; - - /* - * (non-Javadoc) - * - * @see org.eclipse.emf.common.notify.Adapter#getTarget() - */ - public Notifier getTarget() { - return _newTarget; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.emf.common.notify.Adapter#isAdapterForType(java.lang.Object) - */ - public boolean isAdapterForType(Object type) { - return getModel().getClass() == type; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.emf.common.notify.Adapter#notifyChanged(org.eclipse.emf.common.notify.Notification) - */ - public void doNotifyChanged(Notification notification) { - int type = notification.getEventType(); - int featureId = notification.getFeatureID(PageflowPackage.class); - // FC2PFTransformer.getInstance().NotifyChanged(notification, - // getPFLink()); - switch (type) { - case Notification.ADD: - case Notification.ADD_MANY: - case Notification.REMOVE: - case Notification.SET: - if (featureId == PageflowPackage.PF_LINK__OUTCOME - || featureId == PageflowPackage.PF_LINK__SOURCE - || featureId == PageflowPackage.PF_LINK__TARGET) { - PageflowAnnotationUtil - .validateLink(PageflowLinkEditPart.this); - } - - refreshVisuals(); - break; - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.emf.common.notify.Adapter#setTarget(org.eclipse.emf.common.notify.Notifier) - */ - public void setTarget(Notifier newTarget) { - this._newTarget = newTarget; - } - - } - - /* - * (non-Javadoc) - * - * @see EditPart#activate() - */ - public void activate() { - getPFLink().eAdapters().add(adapter); - //PageflowLink element = (PageflowLink) getModel(); - super.activate(); - } - - /* - * (non-Javadoc) - * - * @see EditPart#deactivate() - */ - public void deactivate() { - // getPFLink().eAdapters().remove(adapter); - // PageflowLink element = (PageflowLink) getModel(); - // NavigationCaseType navCase = ((NavigationCaseType) element - // .getFCElements().getData().get(0)); - // navCase.eAdapters().remove(fcAdapter); - // TreeIterator iterator = navCase.eAllContents(); - // while (iterator.hasNext()) { - // ((EObject) iterator.next()).eAdapters().remove(fcAdapter); - // } - - super.deactivate(); - } - - /* - * (non-Javadoc) - * - * @see IAdaptable#getAdapter(java.lang.Class) - */ - public Object getAdapter(Class key) { - /* - * override the default behavior defined in AbstractEditPart which would - * expect the model to be a property sourced. instead the editpart can - * provide a property source - */ - if (key == IPropertySource.class) { - return getPropertySource(); - } - return super.getAdapter(key); - } - - /* - * (non-Javadoc) - * - * @see PageflowElementEditPart#getPropertySource() - */ - protected IPropertySource getPropertySource() { - if (propertySource == null) { - propertySource = new PageflowLinkPropertySource(getPFLink()); - } - return propertySource; - } - - /* - * (non-Javadoc) - * - * @see AbstractEditPart#refreshVisuals() - */ - protected void refreshVisuals() { - super.refreshVisuals(); - resetLabel(); - if (getConnectionRouterStyle() == ILayerPanePreference.LINE_ROUTING_MANUAL) { - refreshBendpoints(); - } - } - - /** - * set the bendpoint constraints of the pflink connection - * - */ - protected void refreshBendpoints() { - // bendpoints stored in pflink - List modelConstraint = getPFLink().getBendPoints(); - // bendpoint constraint list - List figureConstraint = new ArrayList(); - for (int i = 0; i < modelConstraint.size(); i++) { - PageflowLinkBendpoint wbp = (PageflowLinkBendpoint) modelConstraint - .get(i); - RelativeBendpoint rbp = new RelativeBendpoint(getConnectionFigure()); - rbp.setRelativeDimensions(wbp.getFirstRelativeDimension(), wbp - .getSecondRelativeDimension()); - rbp.setWeight((i + 1) / ((float) modelConstraint.size() + 1)); - figureConstraint.add(rbp); - } - // set the router constaints. - getConnectionFigure().setRoutingConstraint(figureConstraint); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.editparts.IConnectionPreference#setLineWidth(int) - */ - public void setLineWidth(int w) { - ((PFLinkFigure) getFigure()).setLineWidth(w); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.editparts.IConnectionPreference#setLabelVisible(boolean) - */ - public void setLabelVisible(boolean b) { - ((PFLinkFigure) getFigure()).setLabelVisible(b); - - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.editparts.IFigurePreference#setForegroundColor(org.eclipse.swt.graphics.Color) - */ - public void setForegroundColor(Color c) { - ((PFLinkFigure) getFigure()).setForegroundColor(c); - - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.editparts.IFigurePreference#setBackgroundColor(org.eclipse.swt.graphics.Color) - */ - public void setBackgroundColor(Color c) { - ((PFLinkFigure) getFigure()).setBackgroundColor(c); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.editparts.IFigurePreference#setFont(org.eclipse.swt.graphics.Font) - */ - public void setFont(Font f) { - ((PFLinkFigure) getFigure()).setFont(f); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.editparts.IConnectionPreference#setLabelForeground(org.eclipse.swt.graphics.Color) - */ - public void setLabelForegroundColor(Color c) { - ((PFLinkFigure) getFigure()).setLabelForegroundColor(c); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.editparts.IConnectionPreference#setLabelBackground(org.eclipse.swt.graphics.Color) - */ - public void setLabelBackgroundColor(Color c) { - ((PFLinkFigure) getFigure()).setLabelBackgroundColor(c); - } - - private boolean needDrawingLabel() { - return (((PageflowLink) getModel()).getOutcome() != null && ((PageflowLink) getModel()) - .getOutcome().trim().length() > 0); - } - - private boolean needDrawingAction() { - return (((PageflowLink) getModel()).getFromaction() != null && ((PageflowLink) getModel()) - .getFromaction().trim().length() > 0); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.editparts.IEditPartDecorator#decorateEditPart() - */ - public void addAnnotation(final Annotation annotation) { - getViewer().getControl().getDisplay().asyncExec(new Runnable() { - public void run() { - ((PFLinkFigure) getFigure()).setImage(getImage(IMG_WARNING)); - ((PFLinkFigure) getFigure()).setToolTipText(annotation - .getText()); - } - }); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.editparts.IEditPartDecorator#undecorateEditPart() - */ - public void removeAnnotation() { - getViewer().getControl().getDisplay().asyncExec(new Runnable() { - public void run() { - ((PFLinkFigure) getFigure()).clearIcon(); - resetLabel(); - } - }); - } - - public void resetLabel() { - StringBuffer tip = new StringBuffer(); - if (needDrawingAction()) { - ((PFLinkFigure) getFigure()).setActionImage(); - tip.append(PageflowMessages.PageflowLinkEditPart_FromAction).append( - ((PageflowLink) getModel()).getFromaction()); - } else if (((PFLinkFigure) getFigure()).getImage() != getImage(IMG_WARNING)) { - ((PFLinkFigure) getFigure()).clearIcon(); - } - if (needDrawingLabel()) { - ((PFLinkFigure) getFigure()).setLabel(((PageflowLink) getModel()) - .getOutcome()); - if (tip.length() > 0) - tip.append("\n"); - tip.append(PageflowMessages.PageflowLinkEditPart_FromOutcome).append( - ((PageflowLink) getModel()).getOutcome()); - } else { - ((PFLinkFigure) getFigure()).clearOutcome(); - } - ((PFLinkFigure) getFigure()).setToolTipText(tip.toString()); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.marker.IEditPartMarker#getMarkerResource() - * - */ - public IResource getMarkerResource() { - // IResource resource = null; - // if (getModel() instanceof PFLink) - // { - // resource = - // FacesConfigUtil.getFacesConfigResource(((PFLink)getModel()).getPageflow()); - // } - // FIXME: it should be changed to link to faces-config file. - IResource resource = WebrootUtil.getResource((EObject) getModel()); - return resource; - } - - public static Image getImage(ImageDescriptor imageDescriptor) { - Image image = EditorPlugin.getDefault().getImageRegistry().get( - imageDescriptor.toString()); - if (null == image) { - EditorPlugin.getDefault().getImageRegistry().put( - imageDescriptor.toString(), imageDescriptor); - image = EditorPlugin.getDefault().getImageRegistry().get( - imageDescriptor.toString()); - } - - return image; - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.editparts.IConnectionPreference#setConnectionRouterStyle(int) - */ - public void setConnectionRouterStyle(int style) { - connectionStyle = style; - if (getConnectionRouterStyle() == ILayerPanePreference.LINE_ROUTING_MANUAL) { - installEditPolicy(EditPolicy.CONNECTION_BENDPOINTS_ROLE, - getBendpointEditPolicy()); - refreshVisuals(); - } else { - removeEditPolicy(EditPolicy.CONNECTION_BENDPOINTS_ROLE); - refreshVisuals(); - } - - } - - /** - * get the foreground color from preference - * - */ - public int getConnectionRouterStyle() { - if (this.connectionStyle == -1) { - IPreferenceStore store = EditorPlugin.getDefault() - .getPreferenceStore(); - String connectionStyle_ = store - .getString(GEMPreferences.LINE_ROUTING); - - if (GEMPreferences.LINE_ROUTING_MANHATTAN.equals(connectionStyle_)) { - this.connectionStyle = ILayerPanePreference.LINE_ROUTING_MANHATTAN; - } else { - this.connectionStyle = ILayerPanePreference.LINE_ROUTING_MANUAL; - } - } - return this.connectionStyle; - } - - public void validate() { - PageflowAnnotationUtil.validateLink(this); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowNodeEditPart.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowNodeEditPart.java deleted file mode 100644 index 8208cd2aa..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowNodeEditPart.java +++ /dev/null @@ -1,479 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart; - -import java.util.Iterator; -import java.util.List; - -import org.eclipse.draw2d.ConnectionAnchor; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.gef.ConnectionEditPart; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.NodeEditPart; -import org.eclipse.gef.Request; -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.requests.DropRequest; -import org.eclipse.gef.tools.DirectEditManager; -import org.eclipse.jdt.ui.JavaElementImageDescriptor; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.text.source.Annotation; -import org.eclipse.jface.viewers.TextCellEditor; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.OpenEditorCommand; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpolicy.PageflowElementEditPolicy; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpolicy.PageflowNodeDirectEditPolicy; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpolicy.PageflowNodeEditPolicy; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.figure.ILabelDecorator; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.figure.PageflowNodeFigure; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.synchronization.PFBatchAdapter; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.util.PageflowAnnotationUtil; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.Image; - -/** - * The base class for the applications EditParts that represent - * PageflowNode-derived objects in the model. This class implements the - * NodeEditPart interface which supports: - * <ul> - * <li>feedback for Connections when they are being - * <li> - * <li>initially connected and when they are disonnected/reconnected</li> - * </ul> - * - * - */ -public class PageflowNodeEditPart extends PageflowElementEditPart implements - NodeEditPart, INodePreference, PFValidator { - - /** property source of pageflow node */ - // private IPropertySource propertySource = null; - protected DirectEditManager editManager; - - private class ImageDecorator implements ILabelDecorator { - private Image decrateImage = null; - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.figures.ILabelDecorator#decorateImage(org.eclipse.swt.graphics.Image, - * java.lang.Object) - */ - public Image decorateImage(Image image, Object element) { - dispose(); - int adornmentFlags = computeAdornmentFlags(element); - if (adornmentFlags != 0) { - ImageDescriptor baseImage = ImageDescriptor.createFromImage(image); - org.eclipse.swt.graphics.Rectangle bounds = image.getBounds(); - decrateImage = (new JavaElementImageDescriptor(baseImage, - adornmentFlags, new org.eclipse.swt.graphics.Point( - bounds.width, bounds.height))).createImage(); - return decrateImage; - } - return image; - } - - /** - * Computes adornment flags for specified object. - * - * Note: This method is for internal use only. Clients should not call - * this method. - * - * @param obj Object to complute flags for. - * @return Adornment flags. - */ - protected int computeAdornmentFlags(Object obj) { - return JavaElementImageDescriptor.WARNING; - } - - /** - * Disposes this instance. - */ - public void dispose() { - if (decrateImage != null) { - decrateImage.dispose(); - } - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.figures.ILabelDecorator#decorateText(java.lang.String, - * java.lang.Object) - */ - public String decorateText(String text, Object element) { - // TODO Auto-generated method stub - return null; - } - - } - - /** - * Disposes this instance. - */ - public void dispose() { - if (imageDecorator != null) { - imageDecorator.dispose(); - } - } - - private ImageDecorator imageDecorator = null; - - /** - * Creates a new PageflowNodeEditPart instance. - * - * @param element - - * pageflow node - */ - public PageflowNodeEditPart(PageflowNode element) { - super(element); - } - - /** - * get the pageflow node - * - * @return - pageflow node - */ - public PageflowNode getPageflowNode() { - return (PageflowNode) getModel(); - } - - /* - * (non-Javadoc) - * - * @see AbstractGraphicalEditPart#getModelSourceConnections() - */ - protected List getModelSourceConnections() { - return getPageflowNode().getOutlinks(); - } - - /* - * (non-Javadoc) - * - * @see AbstractGraphicalEditPart#getModelTargetConnections() - */ - protected List getModelTargetConnections() { - return getPageflowNode().getInlinks(); - } - - /** - * Returns the Figure of this, as a node type figure. - * - * @return - Figure as a NodeFigure. - */ - protected PageflowNodeFigure getPageflowNodeFigure() { - return (PageflowNodeFigure) getFigure(); - } - - public Adapter createEMFAdapter() { - return new PFBatchAdapter() { - /** - * when ports are added to a PageflowNode, add this EditPart as a - * listener on the port so that it gets notified of PFLinks being - * added or removed. When links are added or removed from a port - * owned by the PageflowNode of this EditPart, refresh the - * connections. - */ - public void doNotifyChanged(Notification notification) { - int type = notification.getEventType(); - // FC2PFTransformer.getInstance().NotifyChanged(notification, - // (PageflowElement) getModel()); - switch (type) { - case Notification.ADD: - case Notification.ADD_MANY: - case Notification.REMOVE: - case Notification.REMOVE_MANY: - if (notification.getNewValue() instanceof PageflowLink) { - refreshTargetConnections(); - refreshSourceConnections(); - validate(); - } - break; - - case Notification.SET: - int featureId = notification - .getFeatureID(PageflowPackage.class); - if (needValidation(featureId)) { - validate(); - } - refreshVisuals(); - break; - } - } - }; - } - - private boolean needValidation(int featureId) { - if (getModel() instanceof PageflowPage) { - if (featureId == PageflowPackage.PF_PAGE__PATH) { - return true; - } - } - return false; - } - - public void validate() { - if (getModel() instanceof PageflowPage) { - PageflowAnnotationUtil.validatePage(this); - } - } - - /* - * (non-Javadoc) - * - * @see AbstractEditPart#createEditPolicies() - */ - protected void createEditPolicies() { - // install the edit policy to handle connection creation - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, - new PageflowNodeEditPolicy()); - - installEditPolicy(EditPolicy.COMPONENT_ROLE, - new PageflowElementEditPolicy()); - - // install the direct policy - installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, - new PageflowNodeDirectEditPolicy()); - } - - /* - * (non-Javadoc) - * - * @see NodeEditPart#getSourceConnectionAnchor(ConnectionEditPart) - */ - public ConnectionAnchor getSourceConnectionAnchor( - ConnectionEditPart connection) { - PageflowLink link = (PageflowLink) connection.getModel(); - return getPageflowNodeFigure().getSourceConnectionAnchorAt( - new Point(link.getSource().getX(), link.getSource().getY())); - } - - /* - * (non-Javadoc) - * - * @see NodeEditPart#getSourceConnectionAnchor(Request) - */ - public ConnectionAnchor getSourceConnectionAnchor(Request request) { - Point pt = new Point(((DropRequest) request).getLocation()); - return getPageflowNodeFigure().getSourceConnectionAnchorAt(pt); - } - - /* - * (non-Javadoc) - * - * @see NodeEditPart#getTargetConnectionAnchor(ConnectionEditPart) - */ - public ConnectionAnchor getTargetConnectionAnchor( - ConnectionEditPart connection) { - PageflowLink link = (PageflowLink) connection.getModel(); - return getPageflowNodeFigure().getTargetConnectionAnchorAt( - new Point(link.getTarget().getX(), link.getTarget().getY())); - } - - /* - * (non-Javadoc) - * - * @see NodeEditPart#getTargetConnectionAnchor(Request) - */ - public ConnectionAnchor getTargetConnectionAnchor(Request request) { - Point pt = new Point(((DropRequest) request).getLocation()); - return getPageflowNodeFigure().getTargetConnectionAnchorAt(pt); - } - - /* - * (non-Javadoc) - * - * @see AbstractEditPart#refreshVisuals() - */ - protected void refreshVisuals() { - super.refreshVisuals(); - - getPageflowNodeFigure().setText(getPageflowNode().getName()); - } - - /** - * make this a listener on its ports - */ - public void activate() { - super.activate(); - - Iterator it; - - it = getPageflowNode().getInlinks().iterator(); - while (it.hasNext()) { - PageflowLink link = (PageflowLink) it.next(); - - hookIntoPageflowElement(link); - } - - it = getPageflowNode().getOutlinks().iterator(); - while (it.hasNext()) { - PageflowLink link = (PageflowLink) it.next(); - - hookIntoPageflowElement(link); - } - } - - /** - * remove this as a listener on its ports - */ - public void deactivate() { - super.deactivate(); - dispose(); - Iterator it; - - it = getPageflowNode().getInlinks().iterator(); - while (it.hasNext()) { - PageflowLink link = (PageflowLink) it.next(); - - unhookFromPageflowElement(link); - } - - it = getPageflowNode().getOutlinks().iterator(); - while (it.hasNext()) { - PageflowLink link = (PageflowLink) it.next(); - - unhookFromPageflowElement(link); - } - } - - /** - * perfrom direct edit request - * - */ - protected void performDirectEdit() { - if (editManager == null) { - Label l = ((PageflowNodeFigure) getFigure()).getLabel(); - editManager = new PageflowDirectEditManager(this, - TextCellEditor.class, new DirectEditCellEditorLocator(l), l); - } - editManager.show(); - } - - /** - * perform double click request - * - */ - protected void performOpen() { - // only Page and Action support the double-click commands - if (getModel() instanceof PageflowPage) { - // CommandStack stack = - // getViewer().getEditDomain().getCommandStack(); - Command command = new OpenEditorCommand(this); - if (command != null && command.canExecute()) { - // stack.execute(command); - command.execute(); - } - } - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.editparts.IFigurePreference#setForegroundColor(org.eclipse.swt.graphics.Color) - */ - public void setForegroundColor(Color c) { - getPageflowNodeFigure().setForegroundColor(c); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.editparts.IFigurePreference#setBackgroundColor(org.eclipse.swt.graphics.Color) - */ - public void setBackgroundColor(Color c) { - getPageflowNodeFigure().setBackgroundColor(c); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.editparts.IFigurePreference#setFont(org.eclipse.swt.graphics.Font) - */ - public void setFont(Font f) { - getPageflowNodeFigure().setFont(f); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.editparts.INodePreference#setTextPlacement(int) - */ - public void setTextPlacement(int where) { - getPageflowNodeFigure().setTextPlacement(where); - - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.editparts.IEditPartDecorator#decorateEditPart() - */ - public void addAnnotation(final Annotation annotation) { - getViewer().getControl().getDisplay().asyncExec(new Runnable() { - public void run() { - getPageflowNodeFigure().setImage( - getDecoratedImage((PageflowElement) getModel())); - getPageflowNodeFigure().setToolTipText(annotation.getText()); - } - - }); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.editparts.IEditPartDecorator#undecorateEditPart() - */ - public void removeAnnotation() { - getViewer().getControl().getDisplay().asyncExec(new Runnable() { - public void run() { - getPageflowNodeFigure().setImage( - getImage((PageflowElement) getModel())); - getPageflowNodeFigure().setToolTipText(null); - } - - }); - } - - /** - * Returns the image for the pageflow element. - * - * @param element - - * pageflow element - * @return - the image for the pageflow element. - */ - private Image getDecoratedImage(PageflowElement element) { - Image decoratedImage = getImage(element); - - decoratedImage = getImageDecorator().decorateImage(getImage(element), - null); - - return decoratedImage; - } - - private ImageDecorator getImageDecorator() { - if (imageDecorator == null) { - imageDecorator = new ImageDecorator(); - } - return imageDecorator; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowTreeEditPart.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowTreeEditPart.java deleted file mode 100644 index 8b945157b..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowTreeEditPart.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow; - -/** - * The <code>TreeEditPart</code> implementation for a pageflow. - * - * - */ -public class PageflowTreeEditPart extends PageflowElementTreeEditPart { - - /** - * Creates a new PageflowTreeEditPart instance. - * - * @param pageflow - */ - public PageflowTreeEditPart(Pageflow pageflow) { - super(pageflow); - } - - /* - * (non-Javadoc) - * - * @see AbstractEditPart#getModelChildren() - */ - protected List getModelChildren() { - List children_ = getPageflow().getNodes(); - - return new ArrayList(children_); - } - - /** - * Returns the model as <code>Pageflow</code>. - * - * @return the model as <code>Pageflow</code> - */ - public Pageflow getPageflow() { - return (Pageflow) getModel(); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowTreePartFactory.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowTreePartFactory.java deleted file mode 100644 index 96deb0500..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpart/PageflowTreePartFactory.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart; - -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPartFactory; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement; - -public class PageflowTreePartFactory implements EditPartFactory { - /* - * (non-Javadoc) - * - * @see EditPartFactory#createEditPart() - */ - public EditPart createEditPart(EditPart context, Object model) { - - if (model instanceof Pageflow) { - return new PageflowTreeEditPart((Pageflow) model); - - } else if (model instanceof PageflowElement) { - return new PageflowElementTreeEditPart((PageflowElement) model); - } - - return null; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpolicy/PFLinkBendpointEditPolicy.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpolicy/PFLinkBendpointEditPolicy.java deleted file mode 100644 index 718b7ac1c..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpolicy/PFLinkBendpointEditPolicy.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpolicy; - -import org.eclipse.draw2d.Connection; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.editpolicies.BendpointEditPolicy; -import org.eclipse.gef.requests.BendpointRequest; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.CreateBendpointCommand; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.DeleteBendpointCommand; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.MoveBendpointCommand; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink; - -public class PFLinkBendpointEditPolicy extends BendpointEditPolicy { - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.editpolicies.BendpointEditPolicy#getCreateBendpointCommand(org.eclipse.gef.requests.BendpointRequest) - */ - protected Command getCreateBendpointCommand(BendpointRequest request) { - CreateBendpointCommand createCmd = new CreateBendpointCommand(); - Point p = request.getLocation(); - Connection conn = getConnection(); - - conn.translateToRelative(p); - - createCmd.setLocation(p); - Point ref1 = getConnection().getSourceAnchor().getReferencePoint(); - Point ref2 = getConnection().getTargetAnchor().getReferencePoint(); - - conn.translateToRelative(ref1); - conn.translateToRelative(ref2); - - createCmd.setRelativeDimensions(p.getDifference(ref1), p - .getDifference(ref2)); - createCmd.setPFLink((PageflowLink) request.getSource().getModel()); - createCmd.setIndex(request.getIndex()); - return createCmd; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.editpolicies.BendpointEditPolicy#getDeleteBendpointCommand(org.eclipse.gef.requests.BendpointRequest) - */ - protected Command getDeleteBendpointCommand(BendpointRequest request) { - DeleteBendpointCommand deleteCom = new DeleteBendpointCommand(); - Point p = request.getLocation(); - deleteCom.setLocation(p); - deleteCom.setPFLink((PageflowLink) request.getSource().getModel()); - deleteCom.setIndex(request.getIndex()); - return deleteCom; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.editpolicies.BendpointEditPolicy#getMoveBendpointCommand(org.eclipse.gef.requests.BendpointRequest) - */ - protected Command getMoveBendpointCommand(BendpointRequest request) { - MoveBendpointCommand moveCmd = new MoveBendpointCommand(); - Point p = request.getLocation(); - Connection conn = getConnection(); - - conn.translateToRelative(p); - - moveCmd.setLocation(p); - - Point ref1 = getConnection().getSourceAnchor().getReferencePoint(); - Point ref2 = getConnection().getTargetAnchor().getReferencePoint(); - - conn.translateToRelative(ref1); - conn.translateToRelative(ref2); - - moveCmd.setRelativeDimensions(p.getDifference(ref1), p - .getDifference(ref2)); - moveCmd.setPFLink((PageflowLink) request.getSource().getModel()); - moveCmd.setIndex(request.getIndex()); - return moveCmd; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpolicy/PFLinkEditPolicy.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpolicy/PFLinkEditPolicy.java deleted file mode 100644 index 5f098ea76..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpolicy/PFLinkEditPolicy.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpolicy; - -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.editpolicies.ConnectionEditPolicy; -import org.eclipse.gef.requests.GroupRequest; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.ConnectionCommand; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.DeleteConnectionCommand; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink; - -public class PFLinkEditPolicy extends ConnectionEditPolicy { - - public PFLinkEditPolicy() { - super(); - } - - /* - * (non-Javadoc) - * - * @see ConnectionEditPolicy#getDeleteCommand - */ - protected Command getDeleteCommand(GroupRequest request) { - ConnectionCommand c = new DeleteConnectionCommand(); - c.setPFLink((PageflowLink) getHost().getModel()); - return c; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpolicy/PFLinkEndpointEditPolicy.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpolicy/PFLinkEndpointEditPolicy.java deleted file mode 100644 index 06a9e39f9..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpolicy/PFLinkEndpointEditPolicy.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpolicy; - -import org.eclipse.draw2d.PolylineConnection; -import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.preference.GEMPreferences; - -public class PFLinkEndpointEditPolicy extends ConnectionEndpointEditPolicy { - /** - * - */ - public PFLinkEndpointEditPolicy() { - super(); - } - - /* - * (non-Javadoc) - * - * @see ConnectionEndpointEditPolicy#addSelectionHandles - */ - protected void addSelectionHandles() { - super.addSelectionHandles(); - IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore(); - int connectionWidth = store.getInt(GEMPreferences.LINE_WIDTH); - getConnectionFigure().setLineWidth(connectionWidth + 1); - } - - /* - * (non-Javadoc) - * - * @see ConnectionEndpointEditPolicy#getConnectionFigure - */ - protected PolylineConnection getConnectionFigure() { - return (PolylineConnection) ((GraphicalEditPart) getHost()).getFigure(); - } - - /* - * (non-Javadoc) - * - * @see ConnectionEndpointEditPolicy#removeSelectionHandles - */ - protected void removeSelectionHandles() { - super.removeSelectionHandles(); - IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore(); - int connectionWidth = store.getInt(GEMPreferences.LINE_WIDTH); - getConnectionFigure().setLineWidth(connectionWidth); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpolicy/PageflowContainerEditPolicy.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpolicy/PageflowContainerEditPolicy.java deleted file mode 100644 index f6d9c7c47..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpolicy/PageflowContainerEditPolicy.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpolicy; - -import java.util.List; - -import org.eclipse.gef.EditPart; -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.commands.CompoundCommand; -import org.eclipse.gef.editpolicies.ContainerEditPolicy; -import org.eclipse.gef.requests.CreateRequest; -import org.eclipse.gef.requests.GroupRequest; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.OrphanChildCommand; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode; - -public class PageflowContainerEditPolicy extends ContainerEditPolicy { - /* - * (non-Javadoc) - * - * @see ContainerEditPolicy#getCreateCommand() - */ - protected Command getCreateCommand(CreateRequest request) { - return null; - } - - /* - * (non-Javadoc) - * - * @see ContainerEditPolicy#getOrphanChildrenCommand() - */ - public Command getOrphanChildrenCommand(GroupRequest request) { - List parts = request.getEditParts(); - CompoundCommand result = new CompoundCommand("orphanchildcommand"); - for (int i = 0; i < parts.size(); i++) { - OrphanChildCommand orphan = new OrphanChildCommand(); - orphan - .setChild((PageflowNode) ((EditPart) parts.get(i)) - .getModel()); - orphan.setParent((Pageflow) getHost().getModel()); - orphan.setLabel("label here"); - result.add(orphan); - } - return result.unwrap(); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpolicy/PageflowElementEditPolicy.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpolicy/PageflowElementEditPolicy.java deleted file mode 100644 index 8175c7cc9..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpolicy/PageflowElementEditPolicy.java +++ /dev/null @@ -1,36 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpolicy; - -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.requests.GroupRequest; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.DeleteNodeCommand; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode; - -public class PageflowElementEditPolicy extends - org.eclipse.gef.editpolicies.ComponentEditPolicy { - /* - * (non-Javadoc) - * - * @see ComponentEditPolicy#createDeleteCommand() - */ - protected Command createDeleteCommand(GroupRequest request) { - Object parent = getHost().getParent().getModel(); - DeleteNodeCommand deleteCmd = new DeleteNodeCommand((Pageflow) parent); - deleteCmd.setParent((Pageflow) parent); - deleteCmd.setChild((PageflowNode) getHost().getModel()); - return deleteCmd; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpolicy/PageflowNodeDirectEditPolicy.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpolicy/PageflowNodeDirectEditPolicy.java deleted file mode 100644 index c89d648c8..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpolicy/PageflowNodeDirectEditPolicy.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpolicy; - -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.editpolicies.DirectEditPolicy; -import org.eclipse.gef.requests.DirectEditRequest; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.RenameNodeCommand; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode; - -/** - * EditPolicy for the direct editing of pageflow node's name. - * - * @author Xiaoguang Zhang - */ -public class PageflowNodeDirectEditPolicy extends DirectEditPolicy { - - /* - * (non-javadoc) - * - * @see DirectEditPolicy#getDirectEditCommand(DirectEditRequest) - */ - protected Command getDirectEditCommand(DirectEditRequest request) { - RenameNodeCommand cmd = new RenameNodeCommand(); - cmd.setSource((PageflowNode) getHost().getModel()); - cmd.setOldName(((PageflowNode) getHost().getModel()).getName()); - cmd.setName((String) request.getCellEditor().getValue()); - return cmd; - } - - /* - * (non-javadoc) - * - * @see DirectEditPolicy#showCurrentEditValue(DirectEditRequest) - */ - protected void showCurrentEditValue(DirectEditRequest request) { - // String value = (String)request.getCellEditor().getValue(); - // ((PageflowNodeFigure)getHostFigure()).setText(value); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpolicy/PageflowNodeEditPolicy.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpolicy/PageflowNodeEditPolicy.java deleted file mode 100644 index d7024f33b..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpolicy/PageflowNodeEditPolicy.java +++ /dev/null @@ -1,163 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpolicy; - -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.Connection; -import org.eclipse.draw2d.PolylineConnection; -import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.gef.Request; -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy; -import org.eclipse.gef.requests.CreateConnectionRequest; -import org.eclipse.gef.requests.ReconnectRequest; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.action.OpenEditorAction; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.ConnectionCommand; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.ConnectionCommandFactory; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.OpenEditorCommand; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowNodeEditPart; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.figure.PageflowNodeFigure; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowNodeImpl; -import org.eclipse.jst.jsf.facesconfig.ui.preference.GEMPreferences; - -public class PageflowNodeEditPolicy extends GraphicalNodeEditPolicy { - /* - * (non-Javadoc) - * - * @see GraphicalNodeEditPolicy#createDummyConnection() - */ - protected Connection createDummyConnection(Request req) { - PolylineConnection conn = new PolylineConnection(); - conn.setLineWidth(getLineWidth()); - conn.setForegroundColor(ColorConstants.black); - - return conn; - } - - /** - * get the connection line width from preference. - */ - private int getLineWidth() { - IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore(); - int lineWidth = store.getInt(GEMPreferences.LINE_WIDTH); - return lineWidth; - } - - /* - * (non-Javadoc) - * - * @see GraphicalNodeEditPolicy#getConnectionCompleteCommand() - */ - protected Command getConnectionCompleteCommand( - CreateConnectionRequest request) { - ConnectionCommand command = (ConnectionCommand) request - .getStartCommand(); - // ConnectionAnchor anchor = - // getPageflowNodeEditPart().getTargetConnectionAnchor(request); - - command.setTarget(getPageflowNode()); - - return command; - } - - /* - * (non-Javadoc) - * - * @see GraphicalNodeEditPolicy#getConnectionCreateCommand() - */ - protected Command getConnectionCreateCommand(CreateConnectionRequest request) { - ConnectionCommand command = ConnectionCommandFactory - .createCommand(request); - command.setPFLink((PageflowLink) request.getNewObject()); - PageflowNode flowObject = getPageflowNode(); - command.setSource(flowObject); - request.setStartCommand(command); - return command; - } - - /** - * get the edit part of pageflow node - * - * @return - the edit part of pageflow node - */ - protected PageflowNodeEditPart getPageflowNodeEditPart() { - return (PageflowNodeEditPart) getHost(); - } - - /** - * get the pageflow node - * - * @return - the pageflow node - */ - protected PageflowNode getPageflowNode() { - return (PageflowNode) getHost().getModel(); - } - - /* - * (non-Javadoc) - * - * @see GraphicalNodeEditPolicy#getReconnectTargetCommand() - */ - protected Command getReconnectTargetCommand(ReconnectRequest request) { - ConnectionCommand cmd = ConnectionCommandFactory.createCommand(request); - cmd - .setPFLink((PageflowLink) request.getConnectionEditPart() - .getModel()); - cmd.setTarget(getPageflowNode()); - return cmd; - } - - /* - * (non-Javadoc) - * - * @see GraphicalNodeEditPolicy#getReconnectSourceCommand() - */ - protected Command getReconnectSourceCommand(ReconnectRequest request) { - ConnectionCommand cmd = ConnectionCommandFactory.createCommand(request); - cmd - .setPFLink((PageflowLink) request.getConnectionEditPart() - .getModel()); - cmd.setSource(getPageflowNode()); - return cmd; - } - - /* - * (non-Javadoc) - * - * @see GraphicalNodeEditPolicy#getCommand() - */ - public Command getCommand(Request request) { - if (OpenEditorAction.OPEN_EDITOR_REQUEST.equals(request.getType())) { - OpenEditorCommand command = new OpenEditorCommand(getHost()); - - command.setChild((PageflowNodeImpl) getHost().getModel()); - - return command; - } - - return super.getCommand(request); - } - - /** - * return the pageflow node figure - * - * @return - the pageflow node's figure - */ - protected PageflowNodeFigure getPageflowNodeFigure() { - return (PageflowNodeFigure) ((GraphicalEditPart) getHost()).getFigure(); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpolicy/PageflowNodeSelectionEditPolicy.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpolicy/PageflowNodeSelectionEditPolicy.java deleted file mode 100644 index fb0465df2..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpolicy/PageflowNodeSelectionEditPolicy.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpolicy; - -import org.eclipse.gef.editpolicies.NonResizableEditPolicy; - -/** - * Handles selection of Node. Primary selection is denoted by highlight and a - * focus rectangle. Normal selection is denoted by highlight only. - * - * @author xgzhang - */ -public class PageflowNodeSelectionEditPolicy extends NonResizableEditPolicy { - -// private PageflowNodeFigure getFigure() { -// PageflowNodeEditPart part = (PageflowNodeEditPart) getHost(); -// return ((PageflowNodeFigure) part.getFigure()); -// } - - /** - * @see org.eclipse.gef.editpolicies.SelectionHandlesEditPolicy#hideSelection() - */ - protected void hideSelection() { - super.hideSelection(); - // getFigure().setSelected(false); - } - - /** - * @see org.eclipse.gef.editpolicies.SelectionHandlesEditPolicy#showSelection() - */ - protected void showPrimarySelection() { - super.showPrimarySelection(); - // getFigure().setSelected(true); - } - - /** - * @see org.eclipse.gef.editpolicies.SelectionHandlesEditPolicy#showSelection() - */ - protected void showSelection() { - super.showSelection(); - // getFigure().setSelected(true); - - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpolicy/PageflowXYLayoutEditPolicy.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpolicy/PageflowXYLayoutEditPolicy.java deleted file mode 100644 index 53d0d8c9d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/editpolicy/PageflowXYLayoutEditPolicy.java +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpolicy; - -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.Request; -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.editpolicies.ResizableEditPolicy; -import org.eclipse.gef.editpolicies.XYLayoutEditPolicy; -import org.eclipse.gef.requests.CreateRequest; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.AddNodeCommand; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.CreateNodeCommand; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.command.SetConstraintCommand; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowNodeEditPart; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode; - -public class PageflowXYLayoutEditPolicy extends XYLayoutEditPolicy { - /* - * (non-Javadoc) - * - * @see XYLayoutEditPolicy#createAddCommand() - */ - protected Command createAddCommand(EditPart childEditPart, Object constraint) { - PageflowNode part = (PageflowNode) childEditPart.getModel(); - Rectangle rect = (Rectangle) constraint; - - AddNodeCommand add = new AddNodeCommand(); - add.setParent((Pageflow) getHost().getModel()); - add.setChild(part); - add.setLabel("add"); - add.setDebugLabel("PageFlowXYEP add subpart"); //$NON-NLS-1$ - - SetConstraintCommand setConstraint = new SetConstraintCommand(); - - setConstraint.setLocation(rect); - setConstraint.setPart(part); - setConstraint.setLabel("add"); - setConstraint.setDebugLabel("PageFlowXYEP setConstraint"); //$NON-NLS-1$ - return add.chain(setConstraint); - } - - /* - * (non-Javadoc) - * - * @see XYLayoutEditPolicy#createChangeConstraintCommand() - */ - protected Command createChangeConstraintCommand(EditPart child, - Object constraint) { - SetConstraintCommand locationCommand = new SetConstraintCommand(); - locationCommand.setPart((PageflowNode) child.getModel()); - locationCommand.setLocation((Rectangle) constraint); - return locationCommand; - } - - /* - * (non-Javadoc) - * - * @see XYLayoutEditPolicy#createChildEditPolicy() - */ - protected EditPolicy createChildEditPolicy(EditPart child) { - if (child instanceof PageflowNodeEditPart) { - return new PageflowNodeSelectionEditPolicy(); - } - - return new ResizableEditPolicy(); - } - - /* - * (non-Javadoc) - * - * @see XYLayoutEditPolicy#getCreateCommand() - */ - protected Command getCreateCommand(CreateRequest request) { - CreateNodeCommand create = new CreateNodeCommand(); - create.setParent((Pageflow) getHost().getModel()); - create.setChild((PageflowNode) request.getNewObject()); - Rectangle constraint = (Rectangle) getConstraintFor(request); - create.setLocation(constraint); - create.setLabel("Add"); - return create; - } - - /* - * (non-Javadoc) - * - * @see XYLayoutEditPolicy#getDeleteDependantCommand() - */ - protected Command getDeleteDependantCommand(Request request) { - return null; - } - - /* - * (non-Javadoc) - * - * @see XYLayoutEditPolicy#getOrphanChildrenCommand() - */ - protected Command getOrphanChildrenCommand(Request request) { - return null; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/ConnectionLabel.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/ConnectionLabel.java deleted file mode 100644 index 702e58e09..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/ConnectionLabel.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.figure; - -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.LineBorder; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Image; - -/** - * This label is used in connection figure, which has a border. - * - * @author Xiao-guang Zhang - * - */ -public class ConnectionLabel extends Label { - /** - * - */ - public ConnectionLabel() { - this(null, null); - } - - /** - * @param s - */ - public ConnectionLabel(String s) { - this(s, null); - } - - /** - * @param i - */ - public ConnectionLabel(Image i) { - this(null, i); - } - - /** - * @param s - * @param i - */ - public ConnectionLabel(String s, Image i) { - super(s, i); - - // setBorder(new LineBorder()); - setOpaque(true); - } - - /** - * set the label's border's width - * - * @param w - */ - public void setBorderWidth(int w) { - if (getBorder() != null) { - ((LineBorder) getBorder()).setWidth(w); - } - } - - /** - * set the label's border's color - * - * @param c - */ - public void setBorderColor(Color c) { - if (getBorder() != null) { - ((LineBorder) getBorder()).setColor(c); - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/ILabelDecorator.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/ILabelDecorator.java deleted file mode 100644 index d1d01373a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/ILabelDecorator.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.figure; - -import org.eclipse.swt.graphics.Image; - -/** - * A label decorator decorates the label text and image for some element. The - * original label text and image are obtained by some other means, - * - * - * @author Xiao-guang Zhang - */ -public interface ILabelDecorator { - /** - * Returns an image that is based on the given image, but decorated with - * additional information relating to the state of the provided element. - * - * @param image - * the input image to decorate, or <code>null</code> if the - * element has no image - * @param element - * the element whose image is being decorated - * @return the decorated image, or <code>null</code> if no decoration is - * to be applied - * - * @see org.eclipse.jface.resource.CompositeImageDescriptor - */ - public Image decorateImage(Image image, Object element); - - /** - * Returns a text label that is based on the given text label, but decorated - * with additional information relating to the state of the provided - * element. - * - * - * @param text - * the input text label to decorate - * @param element - * the element whose image is being decorated - * @return the decorated text label, or <code>null</code> if no decoration - * is to be applied - */ - public String decorateText(String text, Object element); - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/NodeLabel.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/NodeLabel.java deleted file mode 100644 index fa5764d82..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/NodeLabel.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.figure; - -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.MarginBorder; -import org.eclipse.swt.graphics.Image; - -/** - * This derived label has simple tooltip support - * - * @author Xiao-guang Zhang - * - */ -public class NodeLabel extends Label { - /** - * - */ - public NodeLabel() { - super(); - } - - /** - * @param s - */ - public NodeLabel(String s) { - super(s); - } - - /** - * @param i - */ - public NodeLabel(Image i) { - super(i); - } - - /** - * @param s - * @param i - */ - public NodeLabel(String s, Image i) { - super(s, i); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.Label#setTextPlacement(int) - */ - public void setTextPlacement(int where) { - super.setTextPlacement(where); - layout(); - invalidate(); - } - - /** - * set tooltip text - * - * @param text - */ - public void setToolTipText(String text) { - Label toolTipLabel = null; - - if (text != null && text.length() > 0) { - toolTipLabel = new Label(text); - toolTipLabel.setBorder(new MarginBorder(3)); - } - - super.setToolTip(toolTipLabel); - } - - /** - * get tooltip's text - * - * @return the tool tip text string - */ - public String getToolTipText() { - if (getToolTip() != null) - return ((Label) getToolTip()).getText(); - return null; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/PFLinkFigure.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/PFLinkFigure.java deleted file mode 100644 index 041fce3c8..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/PFLinkFigure.java +++ /dev/null @@ -1,307 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.figure; - -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.MarginBorder; -import org.eclipse.draw2d.MidpointLocator; -import org.eclipse.draw2d.PolygonDecoration; -import org.eclipse.draw2d.PolylineConnection; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.PreferenceConverter; -import org.eclipse.jface.resource.FontRegistry; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowElementEditPart; -import org.eclipse.jst.jsf.facesconfig.ui.preference.GEMPreferences; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.graphics.Image; - -/** - * - * The figure for pflink, used by pflink edit part, which is a polyline with a - * label control on it, and with tooltip support. - * - * @author Xiao-guang Zhang - */ -public class PFLinkFigure extends PolylineConnection { - /** the label attached to the connection */ - private ConnectionLabel textLabel = null; - - //private ConnectionLabel iconLabel = null; - - /** The label's background color */ - private Color labelBgColor; - - /** The label's foreground color */ - private Color labelFgColor; - - /** The label's visiblity */ - private boolean bLabelVisible = false; - - /** The connection's line width */ - private int lineWidth = 0; - - /** the polygon decoration for connection line */ - private PolygonDecoration arrow; - - /** - * - */ - public PFLinkFigure() { - arrow = new PolygonDecoration(); - arrow.setTemplate(PolygonDecoration.TRIANGLE_TIP); - arrow.setScale(10, getLineWidth() * 2); - setTargetDecoration(arrow); - setForegroundColor(getForegroundColor()); - } - - /** - * set the connection's label string - * - * @param strLabel - */ - public void setLabel(String strLabel) { - if (null != strLabel) { - if (textLabel == null) { - textLabel = new ConnectionLabel(); - textLabel.setFont(getLabelFont()); - textLabel.setBackgroundColor(getLabelBackgroundColor()); - textLabel.setForegroundColor(getLabelForegroundColor()); - setLineWidth(getLineWidth()); - setLabelVisible(getLabelVisible()); - setForegroundColor(getForegroundColor()); - add(textLabel, new MidpointLocator(this, 1)); - } - // textLabel.setVisible(true); - textLabel.setText(strLabel); - } - } - - public void clearIcon() { - setImage(null); - } - - public void clearOutcome() { - setLabel(""); - } - - /** - * set the connection's label string - * - * @param image - */ - public void setImage(Image image) { - if (textLabel == null) { - textLabel = new ConnectionLabel(); - textLabel.setFont(getLabelFont()); - textLabel.setBackgroundColor(getLabelBackgroundColor()); - textLabel.setForegroundColor(getLabelForegroundColor()); - setLineWidth(getLineWidth()); - setLabelVisible(getLabelVisible()); - setForegroundColor(getForegroundColor()); - add(textLabel, new MidpointLocator(this, 0)); - } - textLabel.setIcon(image); - } - - public void setActionImage() { - ImageDescriptor imageDescriptor = PageflowElementEditPart.IMG_ACTION; - Image image = EditorPlugin.getDefault().getImageRegistry().get( - imageDescriptor.toString()); - if (null == image) { - EditorPlugin.getDefault().getImageRegistry().put( - imageDescriptor.toString(), imageDescriptor); - image = EditorPlugin.getDefault().getImageRegistry().get( - imageDescriptor.toString()); - } - setImage(image); - } - - public Image getImage() { - if (textLabel != null) - { - return textLabel.getIcon(); - } - return null; - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#setToolTipText() - */ - public void setToolTipText(String text) { - Label toolTipLabel = null; - - if (text != null && text.length() > 0) { - toolTipLabel = new Label(text); - toolTipLabel.setBorder(new MarginBorder(3)); - } - - super.setToolTip(toolTipLabel); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#getToolTipText() - */ - public String getToolTipText() { - if (getToolTip() != null) - return ((Label) getToolTip()).getText(); - return null; - } - - /** - * set the font including label's - * - */ - public void setFont(Font f) { - if (textLabel != null) - textLabel.setFont(f); - super.setFont(f); - } - - /** - * get the label's font from preference - * - */ - private Font getLabelFont() { - FontRegistry registry = JFaceResources.getFontRegistry(); - IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore(); - FontData fontData = PreferenceConverter.getFontData(store, - GEMPreferences.LINE_LABEL_FONT); - if (!registry.get(fontData.toString()).equals(registry.defaultFont())) - return registry.get(fontData.toString()); - - registry.put(fontData.toString(), new FontData[] {fontData}); - return registry.get(fontData.toString()); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.Shape#setLineWidth(int) - */ - public void setLineWidth(int w) { - if (textLabel != null) - textLabel.setBorderWidth(w); - arrow.setScale(10, getLineWidth() * 2); - super.setLineWidth(w); - } - - /** - * get the connection line width from preference. - */ - public int getLineWidth() { - IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore(); - lineWidth = store.getInt(GEMPreferences.LINE_WIDTH); - return lineWidth; - } - - /** - * set label's visibility - * - * @param flag - - * visible or not. - */ - public void setLabelVisible(boolean flag) { - if (textLabel != null) - textLabel.setVisible(flag); - } - - /** - * get the label's visiblity from preference - * - */ - private boolean getLabelVisible() { - IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore(); - bLabelVisible = store.getBoolean(GEMPreferences.SHOW_LINE_LABELS); - return bLabelVisible; - } - - /** - * set the label's foreground color - * - * @param c - */ - public void setLabelForegroundColor(Color c) { - labelFgColor = c; - if (textLabel != null) - textLabel.setForegroundColor(c); - } - - /** - * get the label's foreground color from preference - * - */ - private Color getLabelForegroundColor() { - if (labelFgColor == null) { - IPreferenceStore store = EditorPlugin.getDefault() - .getPreferenceStore(); - labelFgColor = GEMPreferences.getColor(store, - GEMPreferences.LINE_LABEL_FONT_COLOR); - } - return labelFgColor; - } - - /** - * set the label's background color - * - * @param c - */ - public void setLabelBackgroundColor(Color c) { - labelBgColor = c; - if (textLabel != null) - textLabel.setBackgroundColor(c); - } - - /** - * get the label's background color from preference - * - */ - private Color getLabelBackgroundColor() { - if (labelBgColor == null) { - IPreferenceStore store = EditorPlugin.getDefault() - .getPreferenceStore(); - labelBgColor = GEMPreferences.getColor(store, - GEMPreferences.LINE_LABEL_COLOR); - } - return labelBgColor; - } - - /** - * get the foreground color from preference - * - */ - public Color getForegroundColor() { - IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore(); - final Color newFgColor = GEMPreferences.getColor(store, GEMPreferences.LINE_COLOR); - setForegroundColor(newFgColor); - return newFgColor; - } - - /** - * set the figure's foreground, which will also update the label's border's - * color. - */ - public void setForegroundColor(Color c) { - if (textLabel != null) - textLabel.setBorderColor(c); - super.setForegroundColor(c); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/PageflowNodeFigure.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/PageflowNodeFigure.java deleted file mode 100644 index be73575be..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/figure/PageflowNodeFigure.java +++ /dev/null @@ -1,377 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.figure; - -import java.util.Vector; - -import org.eclipse.draw2d.ChopboxAnchor; -import org.eclipse.draw2d.ConnectionAnchor; -import org.eclipse.draw2d.Figure; -import org.eclipse.draw2d.FlowLayout; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.LabelAnchor; -import org.eclipse.draw2d.MarginBorder; -import org.eclipse.draw2d.PositionConstants; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.PreferenceConverter; -import org.eclipse.jface.resource.FontRegistry; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.preference.GEMPreferences; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.graphics.Image; - -/** - * The figure for pageflow node, used by pageflow node edit part. - * - */ -public class PageflowNodeFigure extends Figure { - /** Same connection anchors for source and target */ - protected Vector connectionAnchors = new Vector(1); - - /** label of the pageflow node figure */ - private NodeLabel label; - - /** the foreground color of Label */ - private Color labelFgColor; - - /** the background color of Label */ -// private Color labelBgColor; // TODO: variable is never read because getter is private - - /** the text placement for the label */ - private int textPlacement = PositionConstants.SOUTH; - - public PageflowNodeFigure() { - setLayoutManager(new FlowLayout()); - - // initializeConnectionAnchors(); - } - - /** - * get the source(output) anchor according to the input point. - * - * @param p - - * the input point - * @return - Source ConnectionAnchor - */ - public ConnectionAnchor getSourceConnectionAnchorAt(Point p) { - if (getSourceConnectionAnchors().size() == 0) - return null; - return (ConnectionAnchor) getSourceConnectionAnchors().get(0); - } - - /** - * get the default source anchor - * - * @return - Source ConnectionAnchor - */ - public ConnectionAnchor getSourceConnectionAnchor() { - if (getSourceConnectionAnchors().size() == 0) - return null; - return (ConnectionAnchor) getSourceConnectionAnchors().get(0); - } - - /** - * Get the source connection anchors vector - * - * @return - the vector - */ - private Vector getSourceConnectionAnchors() { - return connectionAnchors; - } - - /** - * get the target (input) connection Anchor according the input point - * - * @param p - - * the input Point - * @return - ConnectionAnchor - */ - public ConnectionAnchor getTargetConnectionAnchorAt(Point p) { - if (getTargetConnectionAnchors().size() == 0) - return null; - return (ConnectionAnchor) getTargetConnectionAnchors().get(0); - } - - /** - * get the default target (input) connection Anchor - * - * @return - ConnectionAnchor - */ - public ConnectionAnchor getTargetConnectionAnchor() { - if (getTargetConnectionAnchors().size() == 0) - return null; - return (ConnectionAnchor) getTargetConnectionAnchors().get(0); - } - - /** - * Get the target connection anchors vector - * - * @return - the vector - */ - private Vector getTargetConnectionAnchors() { - return connectionAnchors; - } - - /** - * update the anchors - * - */ - public void update() { - initializeConnectionAnchors(); - } - - /** - * Initialize the connection anchors - * - */ - private void initializeConnectionAnchors() { - connectionAnchors.removeAllElements(); - ChopboxAnchor inputConnectionAnchor = new LabelAnchor(label); - connectionAnchors.addElement(inputConnectionAnchor); - } - - /** - * get the text placement from preference. - * - */ - private int getTextPlacement() { - IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore(); - String s = store.getString(GEMPreferences.LABEL_PLACEMENT); - if (GEMPreferences.LABEL_PLACEMENT_TOP.equals(s)) - textPlacement = PositionConstants.NORTH; - else if (GEMPreferences.LABEL_PLACEMENT_BOTTOM.equals(s)) - textPlacement = PositionConstants.SOUTH; - else if (GEMPreferences.LABEL_PLACEMENT_LEFT.equals(s)) - textPlacement = PositionConstants.WEST; - else if (GEMPreferences.LABEL_PLACEMENT_RIGHT.equals(s)) - textPlacement = PositionConstants.EAST; - return textPlacement; - } - - /** - * get the label's background color from preference. - * - * @return - */ - // TODO: dead code -// private Color getLabelBackgroundColor() { -// return labelBgColor; -// } - - /** - * get the label's foreground color from preference. - * - * @return - */ - private Color getLabelForegroundColor() { - if (labelFgColor == null) { - IPreferenceStore store = EditorPlugin.getDefault() - .getPreferenceStore(); - labelFgColor = GEMPreferences.getColor(store, - GEMPreferences.FIGURE_LABEL_FONT_COLOR); - } - return labelFgColor; - } - - /** - * get the labe's font from preference. - * - * @return - */ - private Font getLabelFont() { - FontRegistry registry = JFaceResources.getFontRegistry(); - IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore(); - FontData fontData = PreferenceConverter.getFontData(store, - GEMPreferences.FIGURE_LABEL_FONT); - if (!registry.get(fontData.toString()).equals(registry.defaultFont())) - return registry.get(fontData.toString()); - - registry.put(fontData.toString(), new FontData[] {fontData}); - return registry.get(fontData.toString()); - } - - /** - * set the image and text of the figure - * - * @param image - - * the image - * @param str - - * the label - */ - public void setImageText(Image image, String str) { - if (image == null) - setText(str); - else if (str == null) - setImage(image); - else { - if (label == null) { - label = new NodeLabel(str, image); - label.setTextPlacement(getTextPlacement()); - label.setForegroundColor(getLabelForegroundColor()); - label.setFont(getLabelFont()); - add(label); - initializeConnectionAnchors(); - } else { - label.setIcon(image); - label.setText(str); - } - } - } - - /** - * set the image of the figure - * - * @param image - - * the image - */ - public void setImage(Image image) { - if (image == null) - return; - if (label == null) { - label = new NodeLabel(image); - label.setTextPlacement(getTextPlacement()); - label.setForegroundColor(getLabelForegroundColor()); - label.setFont(getLabelFont()); - add(label); - initializeConnectionAnchors(); - } else - label.setIcon(image); - } - - /** - * set the text of the figure - * - * @param str - - * the text - */ - public void setText(String str) { - if (str == null) - return; - if (label == null) { - label = new NodeLabel(str); - label.setTextPlacement(getTextPlacement()); - label.setForegroundColor(getLabelForegroundColor()); - label.setFont(getLabelFont()); - add(label); - initializeConnectionAnchors(); - } else - label.setText(str); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.Figure#useLocalCoordinates() - */ - protected boolean useLocalCoordinates() { - return true; - } - - /** - * Returns the imageBounds. - * - * @return - Rectangle of image - */ - public Rectangle getImageBounds() { - return label.getIconBounds(); - } - - /** - * Returns the textBounds. - * - * @return - Rectangle of text field - */ - public Rectangle getTextBounds() { - return label.getTextBounds(); - } - - /** - * Returns the label. - * - * @return - Label - */ - public Label getLabel() { - return label; - } - - /** - * set the label's backaground - */ - public void setBackgroundColor(Color bg) { -// TODO: var is never read: labelBgColor = bg; - if (label != null) - label.setBackgroundColor(bg); - } - - /** - * set the label's foreground - */ - public void setForegroundColor(Color fg) { - labelFgColor = fg; - - if (label != null) - label.setForegroundColor(fg); - } - - /** - * Set the label's font - */ - public void setFont(Font f) { - if (label != null) - label.setFont(f); - super.setFont(f); - } - - /** - * Set the text placement for the label - * - * @param where - */ - public void setTextPlacement(int where) { - textPlacement = where; - if (label != null) - label.setTextPlacement(where); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#setToolTipText() - */ - public void setToolTipText(String text) { - Label toolTipLabel = null; - - if (text != null && text.length() > 0) { - toolTipLabel = new Label(text); - toolTipLabel.setBorder(new MarginBorder(3)); - } - - super.setToolTip(toolTipLabel); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#getToolTipText() - */ - public String getToolTipText() { - if (getToolTip() != null) - return ((Label) getToolTip()).getText(); - return null; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/layout/PageflowLayoutManager.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/layout/PageflowLayoutManager.java deleted file mode 100644 index 74c3470a9..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/layout/PageflowLayoutManager.java +++ /dev/null @@ -1,550 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.layout; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.draw2d.geometry.Insets; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.draw2d.graph.DirectedGraph; -import org.eclipse.draw2d.graph.DirectedGraphLayout; -import org.eclipse.draw2d.graph.Edge; -import org.eclipse.draw2d.graph.EdgeList; -import org.eclipse.draw2d.graph.Node; -import org.eclipse.draw2d.graph.NodeList; -import org.eclipse.emf.common.util.EList; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowFactory; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.util.PageflowModelManager; - -/** - * This class is a singleton adpater to create the directed graph for the - * specified pageflow model or update the location information of pageflow model - * according to directed graph layout algorithms. - * - * @author Xiao-guang Zhang - */ -public class PageflowLayoutManager { - /** node's default size */ - private static final int NODE_DEFAULT_WIDTH = 50; - - private static final int NODE_DEFAULT_HEIGHT = 50; - - /** - * the margin of the top and left , and margin between each connnected - * directed graph. - */ - private static final int X_SPACE = 50; - - private static final int Y_SPACE = 50; - - /** node's default padding */ - private static final int DEFAULT_PADDING = 30; - - private static PageflowLayoutManager manager; - - private Map copiedLinks = null; - - /** - * constructor of PageflowDirectedGraphAdapter - * - */ - private PageflowLayoutManager() { - // no external instantiation - } - - /** - * return the singleton instance of PageflowDirectedGraphAdapter - * - * @return - the singleton instance of PageflowDirectedGraphAdapter - */ - static public PageflowLayoutManager getInstance() { - if (manager == null) { - manager = new PageflowLayoutManager(); - } - return manager; - } - - /** - * layout pageflow using directed graph layout algorithms - * - * @param pageflow - - * pageflow model - */ - public void layoutPageflow(Pageflow pageflow) { - List selfLoopLinks = removeSelfLoopLinks(pageflow); - - List lstGraph = createGraphs(pageflow); - for (Iterator iter = lstGraph.iterator(); iter.hasNext();) { - DirectedGraph graph = (DirectedGraph) iter.next(); - new DirectedGraphLayout().visit(graph);// .visit(graph); - } - updatePageflow(lstGraph); - - if (selfLoopLinks != null) { - addSelfLoopLinks(pageflow, selfLoopLinks); - } - } - - /** - * remove the self loop links from pageflow, because the layout algorithm - * does not allow it. - * - * @param pageflow - * @return - */ - private List removeSelfLoopLinks(Pageflow pageflow) { - List selfLoopLinks = new ArrayList(); - - if (pageflow.getLinks() != null) { - for (Iterator iter = pageflow.getLinks().iterator(); iter.hasNext();) { - PageflowLink link = (PageflowLink) iter.next(); - - if (link.getSource() == link.getTarget()) { - iter.remove(); - link.getBendPoints().clear(); - selfLoopLinks.add(link); - } - } - } - return selfLoopLinks; - } - - /** - * add back the self loop links with updated bendpoints. - * - * @param pageflow - * @param selfLoopLinks - */ - private void addSelfLoopLinks(Pageflow pageflow, List selfLoopLinks) { - if (pageflow.getLinks() != null && selfLoopLinks != null - && selfLoopLinks.size() > 0) { - EList links = pageflow.getLinks(); - for (Iterator iter = selfLoopLinks.iterator(); iter.hasNext();) { - PageflowLink link = (PageflowLink) iter.next(); - updateSelfLoopLink(link); - links.add(link); - } - } - } - - /** - * Update the bendpoints of the self loop link Follow the following style: - * - * LeftTop-Top | | Left----Node - * - * @param selfLoopLink - */ - public static void updateSelfLoopLink(PageflowLink selfLoopLink) { - PageflowNode sourceNode = selfLoopLink.getSource(); - Rectangle rectNode = getPageflowNodeBounds(sourceNode); - - EList outLinks = sourceNode.getOutlinks(); - if (outLinks != null && outLinks.size() > 0) { - for (Iterator iter = outLinks.iterator(); iter.hasNext();) { - PageflowLink anotherSelfLoopLink = (PageflowLink) iter.next(); - if (anotherSelfLoopLink != selfLoopLink - && anotherSelfLoopLink.getTarget() == sourceNode) { - rectNode = getFitnessRectangle(rectNode, - anotherSelfLoopLink); - } - } - } - - PageflowFactory factory = PageflowModelManager.getFactory(); - PageflowLinkBendpoint bpTop = factory.createPFLinkBendpoint(); - PageflowLinkBendpoint bpLeftTop = factory.createPFLinkBendpoint(); - PageflowLinkBendpoint bpLeft = factory.createPFLinkBendpoint(); - - bpTop.setD1Height(-rectNode.height); - bpTop.setD2Height(-rectNode.height); - - bpLeftTop.setD1Width(-rectNode.width); - bpLeftTop.setD1Height(-rectNode.height); - bpLeftTop.setD2Width(-rectNode.width); - bpLeftTop.setD2Height(-rectNode.height); - - bpLeft.setD1Width(-rectNode.width); - bpLeft.setD2Width(-rectNode.width); - - selfLoopLink.getBendPoints().add(bpTop); - selfLoopLink.getBendPoints().add(bpLeftTop); - selfLoopLink.getBendPoints().add(bpLeft); - } - - /** - * Calculate the fitness rectangle without conflict with the existing self - * loop's rectangle. - * - * @param rectDefault - * @param anotherSelfLoopLink - */ - private static Rectangle getFitnessRectangle(Rectangle rectDefault, - PageflowLink anotherSelfLoopLink) { - EList bendPoints = anotherSelfLoopLink.getBendPoints(); - if (bendPoints != null && bendPoints.size() > 0) { - for (Iterator iterBendPoint = bendPoints.iterator(); iterBendPoint - .hasNext();) { - PageflowLinkBendpoint bendPoint = (PageflowLinkBendpoint) iterBendPoint - .next(); - if (bendPoint.getD1Width() == -rectDefault.width - && bendPoint.getD1Height() == -rectDefault.height) { - rectDefault = new Rectangle(0, 0, rectDefault.width - + DEFAULT_PADDING, rectDefault.height - + DEFAULT_PADDING); - break; - } - } - } - return rectDefault; - } - - /** - * get the pageflow node's bounds, the orginal point is (0,0) - * - * @param pfNode - * @return - */ - private static Rectangle getPageflowNodeBounds(PageflowNode pfNode) { - return new Rectangle(0, 0, 64, 36); - } - - /** - * get the pageflow node's border rectangle - * - * @param pfNode - * @return - */ - private static Rectangle getPageflowNodeRectangle(PageflowNode pfNode) { - Rectangle rectNode = null; - - Rectangle bounds = getPageflowNodeBounds(pfNode); - - rectNode = new Rectangle(pfNode.getX(), pfNode.getY(), bounds.width, - bounds.height); - - return rectNode; - } - - /** - * create the connected subgraphs for the pageflow model, because there - * maybe more than one connected graph in one pageflow definition. - * - * @param pageflow - - * Pageflow model - * @return - the connected subgraphs - */ - private List createGraphs(Pageflow pageflow) { - /** the connected subgraphs */ - List lstGraph = null; - - if (pageflow != null) { - // Graph is not connected totally. - DirectedGraph graph = null; - HashMap nodesMap = new HashMap(); - - NodeList nodes = new NodeList(); - EdgeList edges = new EdgeList(); - - // get all nodes in the pageflow - List pfNodes = pageflow.getNodes(); - if (pfNodes != null) { - for (Iterator iter = pfNodes.iterator(); iter.hasNext();) { - PageflowNode pfNode = (PageflowNode) iter.next(); - Node node = new Node(pfNode); - Rectangle rectNode = null; - rectNode = getPageflowNodeBounds(pfNode); - if (rectNode != null) { - node.width = rectNode.width * 2; - node.height = rectNode.height * 2; - node.setPadding(new Insets(node.height, node.width, - node.height, node.width)); - } else { - node.width = NODE_DEFAULT_WIDTH; - node.height = NODE_DEFAULT_HEIGHT; - node.setPadding(new Insets(DEFAULT_PADDING)); - } - nodesMap.put(pfNode, node); - nodes.add(node); - } - } - // get all edges in the pageflow - List pfLinks = pageflow.getLinks(); - for (Iterator iter = pfLinks.iterator(); iter.hasNext();) { - PageflowLink link = (PageflowLink) iter.next(); - PageflowNode source = link.getSource(); - PageflowNode target = link.getTarget(); - Node sourceNode = (Node) nodesMap.get(source); - Node targetNode = (Node) nodesMap.get(target); - - if (sourceNode != null && targetNode != null) { - Edge edge = new Edge(sourceNode, targetNode); - edges.add(edge); - } - } - - graph = new DirectedGraph(); - - graph.nodes = nodes; - graph.edges = edges; - - // get the connected subgraphs. - lstGraph = new ArrayList(); - lstGraph.add(graph);// ..getConnectedSubGraphs(); - } - return lstGraph; - } - - /** - * update the pageflow according to layout results which are stored in the - * connected subgraphs - * - * @param lstGraph - - * connected subgraphs - * - */ - private void updatePageflow(List lstGraph) { - // y coordiantion of the subgraph's start point - int topSubGraph = 0; - - for (Iterator iter = lstGraph.iterator(); iter.hasNext();) { - // sub graph's bottom - int bottomSubGraph = 0; - DirectedGraph graph = (DirectedGraph) iter.next(); - for (int i = 0; i < graph.nodes.size(); i++) { - Node node = graph.nodes.getNode(i); - if (!(node.data instanceof PageflowNode)) { - continue; - } - PageflowNode pfNode = (PageflowNode) node.data; - pfNode.setX(X_SPACE + node.y); - - pfNode.setY(Y_SPACE + node.x + topSubGraph); - - if ((Y_SPACE + node.x + topSubGraph) > bottomSubGraph) { - bottomSubGraph = Y_SPACE + node.x + topSubGraph; - } - } - topSubGraph = bottomSubGraph + Y_SPACE; - } - } - - /** - * update new pageflow's layout using the existing one. - * @param newPageflow - * @param oldPageflow - */ - public void updatePageflowLayout(Pageflow newPageflow, Pageflow oldPageflow) { - List notUpdatedNodes = new ArrayList(); - - copiedLinks = new HashMap(); - - if (oldPageflow.getNodes().size() > 0) { - for (Iterator iter = newPageflow.getNodes().iterator(); iter - .hasNext();) { - PageflowNode newNode = (PageflowNode) iter.next(); - - if (!updatePageflowNode(newNode, oldPageflow)) { - notUpdatedNodes.add(newNode); - } - } - } else { - notUpdatedNodes.addAll(newPageflow.getNodes()); - } - - if (oldPageflow.getLinks().size() > 0) { - for (Iterator iter = newPageflow.getLinks().iterator(); iter - .hasNext();) { - PageflowLink newLink = (PageflowLink) iter.next(); - - updatePFLink(newLink, oldPageflow); - } - } - - // if there are still some nodes which are not updated, - // they should be check whether there are some layout conflict. - if (notUpdatedNodes.size() > 0) { - resolveConflict(newPageflow, notUpdatedNodes); - } - - } - - /** - * Update pageflow node using the same node - * - * @param object - * @return - the old pageflow node. - */ - private boolean updatePageflowNode(PageflowNode newNode, - Pageflow oldPageflow) { - for (Iterator iter = oldPageflow.getNodes().iterator(); iter.hasNext();) { - PageflowNode oldNode = (PageflowNode) iter.next(); - - if (oldNode instanceof PageflowPage - && newNode instanceof PageflowPage) { - if (((PageflowPage) oldNode).getPath().trim().equals( - ((PageflowPage) newNode).getPath().trim())) { - updatePageflowNode(newNode, oldNode); - return true; - } - } - } - return false; - } - - /** - * Update pageflow node using the same node - * - * @param object - */ - private void updatePageflowNode(PageflowNode newNode, PageflowNode node) { - newNode.setX(node.getX()); - newNode.setY(node.getY()); - } - - /** - * If there are conflict for the nodes, it will resolve it. - * - * @param newPageflow - * @param notUpdatedNodes - */ - private void resolveConflict(Pageflow newPageflow, List notUpdatedNodes) { - for (Iterator iter = notUpdatedNodes.iterator(); iter.hasNext();) { - resolveConflict(newPageflow, (PageflowNode) iter.next()); - } - } - - /** - * Resolve the layout conflict - * - * @param newPageflow - * @param node - */ - private void resolveConflict(Pageflow newPageflow, PageflowNode node) { - Rectangle nodeRect = getPageflowNodeRectangle(node); - boolean bModified = false; - for (int i = 0, size = newPageflow.getNodes().size(); i < size; i++) { - PageflowNode fixedNode = (PageflowNode) newPageflow.getNodes().get( - i); - if (node == fixedNode) { - continue; - } - Rectangle fixedNodeRect = getPageflowNodeRectangle(fixedNode); - if (fixedNodeRect.intersects(nodeRect)) { - nodeRect.x += fixedNodeRect.width + X_SPACE; - nodeRect.y += fixedNodeRect.height + Y_SPACE; - bModified = true; - } - } - if (bModified) { - node.setX(nodeRect.x); - node.setY(nodeRect.y); - } - } - - /** - * Update the link using the same link in the old pageflow - * - * @param newLink - * @param oldPageflow - */ - private void updatePFLink(PageflowLink newLink, Pageflow oldPageflow) { - for (Iterator iter = oldPageflow.getLinks().iterator(); iter.hasNext();) { - PageflowLink oldLink = (PageflowLink) iter.next(); - - if (copiedLinks.get(oldLink) != null) { - continue; - } - - if (isSameLink(newLink, oldLink)) { - updatePFLink(newLink, oldLink); - break; - } - } - } - - /** - * Check whether this two links in differnet pageflow are same or not. - * - * @param newLink - * @param oldLink - * @return - */ - private boolean isSameLink(PageflowLink newLink, PageflowLink oldLink) { - PageflowNode newSource = newLink.getSource(); - PageflowNode newTarget = newLink.getTarget(); - - PageflowNode oldSource = oldLink.getSource(); - PageflowNode oldTarget = oldLink.getTarget(); - - // Page-Page - if (newSource instanceof PageflowPage - && oldSource instanceof PageflowPage - && newTarget instanceof PageflowPage - && oldTarget instanceof PageflowPage) { - if (((PageflowPage) newSource).getPath().trim().equalsIgnoreCase( - ((PageflowPage) oldSource).getPath().trim()) - && ((PageflowPage) newTarget) - .getPath() - .trim() - .equalsIgnoreCase( - ((PageflowPage) oldTarget).getPath().trim())) { - if ((newLink.getOutcome() == null && oldLink.getOutcome() == null) - || (newLink.getOutcome() != null - && oldLink.getOutcome() != null && newLink - .getOutcome().trim().equals( - oldLink.getOutcome().trim()))) { - return true; - } - } - } - - return false; - } - - /** - * Update the link using the same link - * - * @param nodesMap - * @param object - * @return - */ - private PageflowLink updatePFLink(PageflowLink newLink, PageflowLink link) { - PageflowFactory factory = PageflowModelManager.getFactory(); - - newLink.getBendPoints().clear(); - - for (Iterator iter = link.getBendPoints().iterator(); iter.hasNext();) { - PageflowLinkBendpoint bendPoint = (PageflowLinkBendpoint) iter - .next(); - PageflowLinkBendpoint newBendPoint = factory - .createPFLinkBendpoint(); - newBendPoint.setD1Height(bendPoint.getD1Height()); - newBendPoint.setD1Width(bendPoint.getD1Width()); - newBendPoint.setD2Height(bendPoint.getD2Height()); - newBendPoint.setD2Width(bendPoint.getD2Width()); - newLink.getBendPoints().add(newBendPoint); - } - - copiedLinks.put(link, link); - return newLink; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/Pageflow.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/Pageflow.java deleted file mode 100644 index 9f56b7ca6..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/Pageflow.java +++ /dev/null @@ -1,116 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.model; - -import org.eclipse.emf.common.util.EList; - -/** - * <!-- begin-user-doc --> A representation of the model object '<em><b>Pageflow</b></em>'. - * <!-- end-user-doc --> - * - * <p> - * The following features are supported: - * <ul> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow#getNodes <em>Nodes</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow#getLinks <em>Links</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow#getConfigfile <em>Configfile</em>}</li> - * </ul> - * </p> - * - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage#getPageflow() - * @model - * @generated - */ -public interface Pageflow extends PageflowElement { - /** - * Returns the value of the '<em><b>Nodes</b></em>' containment - * reference list. The list contents are of type - * {@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode}. - * It is bidirectional and its opposite is '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode#getPageflow <em>Pageflow</em>}'. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Nodes</em>' containment reference list - * isn't clear, there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * - * @return the value of the '<em>Nodes</em>' containment reference list. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage#getPageflow_Nodes() - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode#getPageflow - * @model type="org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode" - * opposite="pageflow" containment="true" - * @generated - */ - EList getNodes(); - - /** - * Returns the value of the '<em><b>Links</b></em>' containment - * reference list. The list contents are of type - * {@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink}. It - * is bidirectional and its opposite is '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#getPageflow <em>Pageflow</em>}'. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Links</em>' containment reference list - * isn't clear, there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * - * @return the value of the '<em>Links</em>' containment reference list. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage#getPageflow_Links() - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#getPageflow - * @model type="org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PFLink" - * opposite="pageflow" containment="true" - * @generated - */ - EList getLinks(); - - /** - * Returns the value of the '<em><b>Configfile</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Configfile</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * - * @return the value of the '<em>Configfile</em>' attribute. - * @see #setConfigfile(String) - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage#getPageflow_Configfile() - * @model - * @generated - */ - String getConfigfile(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow#getConfigfile <em>Configfile</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @param value - * the new value of the '<em>Configfile</em>' attribute. - * @see #getConfigfile() - * @generated - */ - void setConfigfile(String value); - - /** - * - * @generated NOT - */ - public void connect(PageflowNode source, PageflowNode target, PageflowLink link); - - /** - * - * @generated NOT - */ - public String getDefaultNodeName(Class nodeType); -} -// Pageflow diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/PageflowElement.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/PageflowElement.java deleted file mode 100644 index d0fe7c62e..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/PageflowElement.java +++ /dev/null @@ -1,290 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.model; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.ReferenceElement; - -/** - * <!-- begin-user-doc --> A representation of the model object '<em><b>Element</b></em>'. - * <!-- end-user-doc --> - * - * <p> - * The following features are supported: - * <ul> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement#getName <em>Name</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement#getComment <em>Comment</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement#getX <em>X</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement#getY <em>Y</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement#getWidth <em>Width</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement#getHeight <em>Height</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement#getId <em>Id</em>}</li> - * </ul> - * </p> - * - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage#getPageflowElement() - * @model abstract="true" - * @generated - */ -public interface PageflowElement extends EObject { - /** - * The pageflow model is based on faces-config model, its elements will - * reference faces-config elements with ReferenceElement. - * - * @generated NOT - */ - public ReferenceElement getFCElements(); - - /** - * Returns the value of the '<em><b>Name</b></em>' attribute. The - * default value is <code>"unnamed"</code>. <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Name</em>' attribute isn't clear, there - * really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * - * @return the value of the '<em>Name</em>' attribute. - * @see #setName(String) - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage#getPageflowElement_Name() - * @model default="unnamed" - * @generated - */ - String getName(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement#getName <em>Name</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @param value - * the new value of the '<em>Name</em>' attribute. - * @see #getName() - * @generated - */ - void setName(String value); - - /** - * Returns the value of the '<em><b>Comment</b></em>' attribute. <!-- - * begin-user-doc --> - * <p> - * If the meaning of the '<em>Comment</em>' attribute isn't clear, there - * really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * - * @return the value of the '<em>Comment</em>' attribute. - * @see #setComment(String) - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage#getPageflowElement_Comment() - * @model - * @generated - */ - String getComment(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement#getComment <em>Comment</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @param value - * the new value of the '<em>Comment</em>' attribute. - * @see #getComment() - * @generated - */ - void setComment(String value); - - /** - * Returns the value of the '<em><b>X</b></em>' attribute. The default - * value is <code>"0"</code>. <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>X</em>' attribute isn't clear, there - * really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * - * @return the value of the '<em>X</em>' attribute. - * @see #setX(int) - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage#getPageflowElement_X() - * @model default="0" - * @generated - */ - int getX(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement#getX <em>X</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @param value - * the new value of the '<em>X</em>' attribute. - * @see #getX() - * @generated - */ - void setX(int value); - - /** - * Returns the value of the '<em><b>Y</b></em>' attribute. The default - * value is <code>"0"</code>. <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Y</em>' attribute isn't clear, there - * really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * - * @return the value of the '<em>Y</em>' attribute. - * @see #setY(int) - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage#getPageflowElement_Y() - * @model default="0" - * @generated - */ - int getY(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement#getY <em>Y</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @param value - * the new value of the '<em>Y</em>' attribute. - * @see #getY() - * @generated - */ - void setY(int value); - - /** - * Returns the value of the '<em><b>Width</b></em>' attribute. The - * default value is <code>"-1"</code>. <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Width</em>' attribute isn't clear, there - * really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * - * @return the value of the '<em>Width</em>' attribute. - * @see #setWidth(int) - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage#getPageflowElement_Width() - * @model default="-1" - * @generated - */ - int getWidth(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement#getWidth <em>Width</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @param value - * the new value of the '<em>Width</em>' attribute. - * @see #getWidth() - * @generated - */ - void setWidth(int value); - - /** - * Returns the value of the '<em><b>Height</b></em>' attribute. The - * default value is <code>"-1"</code>. <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Height</em>' attribute isn't clear, there - * really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * - * @return the value of the '<em>Height</em>' attribute. - * @see #setHeight(int) - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage#getPageflowElement_Height() - * @model default="-1" - * @generated - */ - int getHeight(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement#getHeight <em>Height</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @param value - * the new value of the '<em>Height</em>' attribute. - * @see #getHeight() - * @generated - */ - void setHeight(int value); - - /** - * Returns the value of the '<em><b>Id</b></em>' attribute. <!-- - * begin-user-doc --> - * <p> - * If the meaning of the '<em>Id</em>' attribute isn't clear, there - * really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * - * @return the value of the '<em>Id</em>' attribute. - * @see #setId(String) - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage#getPageflowElement_Id() - * @model id="true" required="true" volatile="true" - * @generated - */ - String getId(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement#getId <em>Id</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @param value - * the new value of the '<em>Id</em>' attribute. - * @see #getId() - * @generated - */ - void setId(String value); - - /** - * Returns the value of the '<em><b>Reference Link</b></em>' attribute. - * The default value is <code>""</code>. <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Reference Link</em>' attribute isn't - * clear, there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * - * @return the value of the '<em>Reference Link</em>' attribute. - * @see #setReferenceLink(String) - * @model default="" dataType="org.eclipse.emf.ecore.xml.type.String" - * extendedMetaData="kind='attribute' name='referenceLink'" - * @generated - */ - String getReferenceLink(); - - /** - * Sets the value of the '{@link PageflowElement#getReferenceLink() <em>Reference Link</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @param value - * the new value of the '<em>Reference Link</em>' attribute. - * @see #getReferenceLink() - * @generated - */ - void setReferenceLink(String value); - - /** - * @generated NOT - */ - void notifyModelChanged(Notification nofitification); - - /** - * When the model is modified, the adapters or reference elements should be - * updated. - * - * @generated NOT - */ - void update(); - - /** - * @generated NOT - */ - void dispose(); -} -// PageflowElement diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/PageflowFactory.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/PageflowFactory.java deleted file mode 100644 index 3d52525eb..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/PageflowFactory.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.model; - -import org.eclipse.emf.ecore.EFactory; - -/** - * <!-- begin-user-doc --> The <b>Factory</b> for the model. It provides a - * create method for each non-abstract class of the model. <!-- end-user-doc --> - * - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage - * @generated - */ -public interface PageflowFactory extends EFactory { - /** - * The singleton instance of the factory. <!-- begin-user-doc --> <!-- - * end-user-doc --> - * - * @generated - */ - PageflowFactory eINSTANCE = new org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowFactoryImpl(); - - /** - * Returns a new object of class '<em>Pageflow</em>'. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @return a new object of class '<em>Pageflow</em>'. - * @generated - */ - Pageflow createPageflow(); - - /** - * Returns a new object of class '<em>PF Link</em>'. <!-- begin-user-doc - * --> <!-- end-user-doc --> - * - * @return a new object of class '<em>PF Link</em>'. - * @generated - */ - PageflowLink createPFLink(); - - /** - * Returns a new object of class '<em>PF Page</em>'. <!-- begin-user-doc - * --> <!-- end-user-doc --> - * - * @return a new object of class '<em>PF Page</em>'. - * @generated - */ - PageflowPage createPFPage(); - - /** - * Returns a new object of class '<em>PF Link Bendpoint</em>'. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @return a new object of class '<em>PF Link Bendpoint</em>'. - * @generated - */ - PageflowLinkBendpoint createPFLinkBendpoint(); - - /** - * Returns the package supported by this factory. <!-- begin-user-doc --> - * <!-- end-user-doc --> - * - * @return the package supported by this factory. - * @generated - */ - PageflowPackage getPageflowPackage(); - -} -// PageflowFactory diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/PageflowLink.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/PageflowLink.java deleted file mode 100644 index 5d5f57a1f..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/PageflowLink.java +++ /dev/null @@ -1,308 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.model; - -import java.util.Vector; - -import org.eclipse.emf.common.util.EList; - -/** - * <!-- begin-user-doc --> A representation of the model object '<em><b>PF Link</b></em>'. - * <!-- end-user-doc --> - * - * <p> - * The following features are supported: - * <ul> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#getPageflow <em>Pageflow</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#getTarget <em>Target</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#getSource <em>Source</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#getSmallicon <em>Smallicon</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#getLargeicon <em>Largeicon</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#getFromaction <em>Fromaction</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#getOutcome <em>Outcome</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#isRedirect <em>Redirect</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#getBendPoints <em>Bend Points</em>}</li> - * </ul> - * </p> - * - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage#getPFLink() - * @model - * @generated - */ -public interface PageflowLink extends PageflowElement { - /** - * Returns the value of the '<em><b>Pageflow</b></em>' container reference. - * It is bidirectional and its opposite is '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow#getLinks <em>Links</em>}'. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Pageflow</em>' container reference isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Pageflow</em>' container reference. - * @see #setPageflow(Pageflow) - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage#getPFLink_Pageflow() - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow#getLinks - * @model opposite="links" required="true" - * @generated - */ - Pageflow getPageflow(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#getPageflow <em>Pageflow</em>}' container reference. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Pageflow</em>' container reference. - * @see #getPageflow() - * @generated - */ - void setPageflow(Pageflow value); - - /** - * Returns the value of the '<em><b>Target</b></em>' reference. - * It is bidirectional and its opposite is '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode#getInlinks <em>Inlinks</em>}'. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Target</em>' reference isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Target</em>' reference. - * @see #setTarget(PageflowNode) - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage#getPFLink_Target() - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode#getInlinks - * @model opposite="inlinks" required="true" - * @generated - */ - PageflowNode getTarget(); - - void setTargetPath(String path); - - void setSourcePath(String path); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#getTarget <em>Target</em>}' reference. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Target</em>' reference. - * @see #getTarget() - * @generated - */ - void setTarget(PageflowNode value); - - /** - * Returns the value of the '<em><b>Source</b></em>' reference. - * It is bidirectional and its opposite is '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode#getOutlinks <em>Outlinks</em>}'. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Source</em>' reference isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Source</em>' reference. - * @see #setSource(PageflowNode) - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage#getPFLink_Source() - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode#getOutlinks - * @model opposite="outlinks" required="true" - * @generated - */ - PageflowNode getSource(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#getSource <em>Source</em>}' reference. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Source</em>' reference. - * @see #getSource() - * @generated - */ - void setSource(PageflowNode value); - - /** - * Returns the value of the '<em><b>Smallicon</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Smallicon</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Smallicon</em>' attribute. - * @see #setSmallicon(String) - * @model - * @generated - */ - String getSmallicon(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#getSmallicon <em>Smallicon</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Smallicon</em>' attribute. - * @see #getSmallicon() - * @generated - */ - void setSmallicon(String value); - - /** - * Returns the value of the '<em><b>Largeicon</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Largeicon</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Largeicon</em>' attribute. - * @see #setLargeicon(String) - * @model - * @generated - */ - String getLargeicon(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#getLargeicon <em>Largeicon</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Largeicon</em>' attribute. - * @see #getLargeicon() - * @generated - */ - void setLargeicon(String value); - - /** - * Returns the value of the '<em><b>Fromaction</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Fromaction</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Fromaction</em>' attribute. - * @see #setFromaction(String) - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage#getPFLink_Fromaction() - * @model - * @generated - */ - String getFromaction(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#getFromaction <em>Fromaction</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Fromaction</em>' attribute. - * @see #getFromaction() - * @generated - */ - void setFromaction(String value); - - /** - * Returns the value of the '<em><b>Outcome</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Outcome</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Outcome</em>' attribute. - * @see #setOutcome(String) - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage#getPFLink_Outcome() - * @model - * @generated - */ - String getOutcome(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#getOutcome <em>Outcome</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Outcome</em>' attribute. - * @see #getOutcome() - * @generated - */ - void setOutcome(String value); - - /** - * Returns the value of the '<em><b>Redirect</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Redirect</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Redirect</em>' attribute. - * @see #setRedirect(boolean) - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage#getPFLink_Redirect() - * @model - * @generated - */ - boolean isRedirect(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#isRedirect <em>Redirect</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Redirect</em>' attribute. - * @see #isRedirect() - * @generated - */ - void setRedirect(boolean value); - - /** - * Returns the value of the '<em><b>Bend Points</b></em>' containment reference list. - * The list contents are of type {@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint}. - * It is bidirectional and its opposite is '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint#getLink <em>Link</em>}'. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Bend Points</em>' containment reference list isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Bend Points</em>' containment reference list. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage#getPFLink_BendPoints() - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint#getLink - * @model type="org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PFLinkBendpoint" opposite="link" containment="true" - * @generated - */ - EList getBendPoints(); - - /** - * <!-- begin-user-doc --> insert a new bendpoint to the link <!-- - * end-user-doc --> - * - * @generated NOT - */ - public void insertBendpoint(int index, PageflowLinkBendpoint point); - - /** - * <!-- begin-user-doc --> remove the current bendpoint <!-- end-user-doc - * --> - * - * @generated NOT - */ - public void removeBendpoint(int index); - - /** - * <!-- begin-user-doc --> Set the current bendpoint <!-- end-user-doc --> - * - * @generated NOT - */ - public void setBendpoint(int index, PageflowLinkBendpoint point); - - /** - * <!-- begin-user-doc --> Set a group of bendpoints to reconstruct the link - * <!-- end-user-doc --> - * - * @generated NOT - */ - public void setBendpoints(Vector points); - -} -// PFLink diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/PageflowLinkBendpoint.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/PageflowLinkBendpoint.java deleted file mode 100644 index a0bb298d8..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/PageflowLinkBendpoint.java +++ /dev/null @@ -1,230 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.model; - -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.emf.ecore.EObject; - -/** - * <!-- begin-user-doc --> A representation of the model object '<em><b>PF Link Bendpoint</b></em>'. - * <!-- end-user-doc --> - * - * <p> - * The following features are supported: - * <ul> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint#getD1Width <em>D1 Width</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint#getD1Height <em>D1 Height</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint#getD2Width <em>D2 Width</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint#getD2Height <em>D2 Height</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint#getWeight <em>Weight</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint#getLink <em>Link</em>}</li> - * </ul> - * </p> - * - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage#getPFLinkBendpoint() - * @model - * @generated - */ -public interface PageflowLinkBendpoint extends EObject { - /** - * Returns the value of the '<em><b>D1 Width</b></em>' attribute. <!-- - * begin-user-doc --> - * <p> - * If the meaning of the '<em>D1 Width</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * - * @return the value of the '<em>D1 Width</em>' attribute. - * @see #setD1Width(int) - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage#getPFLinkBendpoint_D1Width() - * @model - * @generated - */ - int getD1Width(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint#getD1Width <em>D1 Width</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @param value - * the new value of the '<em>D1 Width</em>' attribute. - * @see #getD1Width() - * @generated - */ - void setD1Width(int value); - - /** - * Returns the value of the '<em><b>D1 Height</b></em>' attribute. <!-- - * begin-user-doc --> - * <p> - * If the meaning of the '<em>D1 Height</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * - * @return the value of the '<em>D1 Height</em>' attribute. - * @see #setD1Height(int) - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage#getPFLinkBendpoint_D1Height() - * @model - * @generated - */ - int getD1Height(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint#getD1Height <em>D1 Height</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @param value - * the new value of the '<em>D1 Height</em>' attribute. - * @see #getD1Height() - * @generated - */ - void setD1Height(int value); - - /** - * Returns the value of the '<em><b>D2 Width</b></em>' attribute. <!-- - * begin-user-doc --> - * <p> - * If the meaning of the '<em>D2 Width</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * - * @return the value of the '<em>D2 Width</em>' attribute. - * @see #setD2Width(int) - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage#getPFLinkBendpoint_D2Width() - * @model - * @generated - */ - int getD2Width(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint#getD2Width <em>D2 Width</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @param value - * the new value of the '<em>D2 Width</em>' attribute. - * @see #getD2Width() - * @generated - */ - void setD2Width(int value); - - /** - * Returns the value of the '<em><b>D2 Height</b></em>' attribute. <!-- - * begin-user-doc --> - * <p> - * If the meaning of the '<em>D2 Height</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * - * @return the value of the '<em>D2 Height</em>' attribute. - * @see #setD2Height(int) - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage#getPFLinkBendpoint_D2Height() - * @model - * @generated - */ - int getD2Height(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint#getD2Height <em>D2 Height</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @param value - * the new value of the '<em>D2 Height</em>' attribute. - * @see #getD2Height() - * @generated - */ - void setD2Height(int value); - - /** - * Returns the value of the '<em><b>Weight</b></em>' attribute. The - * default value is <code>"0.5"</code>. <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Weight</em>' attribute isn't clear, there - * really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * - * @return the value of the '<em>Weight</em>' attribute. - * @see #setWeight(float) - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage#getPFLinkBendpoint_Weight() - * @model default="0.5" - * @generated - */ - float getWeight(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint#getWeight <em>Weight</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @param value - * the new value of the '<em>Weight</em>' attribute. - * @see #getWeight() - * @generated - */ - void setWeight(float value); - - /** - * Returns the value of the '<em><b>Link</b></em>' container reference. - * It is bidirectional and its opposite is '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#getBendPoints <em>Bend Points</em>}'. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Link</em>' container reference isn't - * clear, there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * - * @return the value of the '<em>Link</em>' container reference. - * @see #setLink(PageflowLink) - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage#getPFLinkBendpoint_Link() - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#getBendPoints - * @model opposite="bendPoints" required="true" - * @generated - */ - PageflowLink getLink(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint#getLink <em>Link</em>}' - * container reference. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @param value - * the new value of the '<em>Link</em>' container reference. - * @see #getLink() - * @generated - */ - void setLink(PageflowLink value); - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated NOT - */ - public Dimension getFirstRelativeDimension(); - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated NOT - */ - public Dimension getSecondRelativeDimension(); - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated NOT - */ - public void setRelativeDimensions(Dimension dim1, Dimension dim2); - -} -// PFLinkBendpoint diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/PageflowNode.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/PageflowNode.java deleted file mode 100644 index fe50af4ac..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/PageflowNode.java +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.model; - -import org.eclipse.emf.common.util.EList; - -/** - * <!-- begin-user-doc --> A representation of the model object '<em><b>Node</b></em>'. - * <!-- end-user-doc --> - * - * <p> - * The following features are supported: - * <ul> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode#getPageflow <em>Pageflow</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode#getOutlinks <em>Outlinks</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode#getInlinks <em>Inlinks</em>}</li> - * </ul> - * </p> - * - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage#getPageflowNode() - * @model abstract="true" - * @generated - */ -public interface PageflowNode extends PageflowElement { - /** - * Returns the value of the '<em><b>Pageflow</b></em>' container - * reference. It is bidirectional and its opposite is '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow#getNodes <em>Nodes</em>}'. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Pageflow</em>' container reference isn't - * clear, there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * - * @return the value of the '<em>Pageflow</em>' container reference. - * @see #setPageflow(Pageflow) - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage#getPageflowNode_Pageflow() - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow#getNodes - * @model opposite="nodes" required="true" - * @generated - */ - Pageflow getPageflow(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode#getPageflow <em>Pageflow</em>}' - * container reference. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @param value - * the new value of the '<em>Pageflow</em>' container - * reference. - * @see #getPageflow() - * @generated - */ - void setPageflow(Pageflow value); - - /** - * Returns the value of the '<em><b>Outlinks</b></em>' reference list. - * The list contents are of type - * {@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink}. It - * is bidirectional and its opposite is '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#getSource <em>Source</em>}'. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Outlinks</em>' reference list isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * - * @return the value of the '<em>Outlinks</em>' reference list. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage#getPageflowNode_Outlinks() - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#getSource - * @model type="org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PFLink" - * opposite="source" - * @generated - */ - EList getOutlinks(); - - /** - * Returns the value of the '<em><b>Inlinks</b></em>' reference list. - * The list contents are of type - * {@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink}. It - * is bidirectional and its opposite is '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#getTarget <em>Target</em>}'. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Inlinks</em>' reference list isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * - * @return the value of the '<em>Inlinks</em>' reference list. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage#getPageflowNode_Inlinks() - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#getTarget - * @model type="org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PFLink" - * opposite="target" - * @generated - */ - EList getInlinks(); - - /** - * @generated NOT - */ - PageflowLink findLinkTo(PageflowNode target); - -} -// PageflowNode diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/PageflowPackage.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/PageflowPackage.java deleted file mode 100644 index ce9358b27..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/PageflowPackage.java +++ /dev/null @@ -1,1161 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.model; - -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EReference; - -/** - * <!-- begin-user-doc --> The <b>Package</b> for the model. It contains - * accessors for the meta objects to represent - * <ul> - * <li>each class,</li> - * <li>each feature of each class,</li> - * <li>each enum,</li> - * <li>and each data type</li> - * </ul> - * <!-- end-user-doc --> - * - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowFactory - * @generated - */ -public interface PageflowPackage extends EPackage { - /** - * The package name. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - String eNAME = "pageflow"; - - /** - * The package namespace URI. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - String eNS_URI = "http://www.sybase.com/suade/pageflow"; - - /** - * The package namespace name. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - String eNS_PREFIX = "pageflow"; - - /** - * The singleton instance of the package. <!-- begin-user-doc --> <!-- - * end-user-doc --> - * - * @generated - */ - PageflowPackage eINSTANCE = org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowPackageImpl - .init(); - - /** - * The meta object id for the '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowElementImpl <em>Element</em>}' - * class. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowElementImpl - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowPackageImpl#getPageflowElement() - * @generated - */ - int PAGEFLOW_ELEMENT = 3; - - /** - * The feature id for the '<em><b>Name</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PAGEFLOW_ELEMENT__NAME = 0; - - /** - * The feature id for the '<em><b>Comment</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PAGEFLOW_ELEMENT__COMMENT = 1; - - /** - * The feature id for the '<em><b>X</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PAGEFLOW_ELEMENT__X = 2; - - /** - * The feature id for the '<em><b>Y</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PAGEFLOW_ELEMENT__Y = 3; - - /** - * The feature id for the '<em><b>Width</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PAGEFLOW_ELEMENT__WIDTH = 4; - - /** - * The feature id for the '<em><b>Height</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PAGEFLOW_ELEMENT__HEIGHT = 5; - - /** - * The feature id for the '<em><b>Id</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PAGEFLOW_ELEMENT__ID = 6; - - /** - * The feature id for the '<em><b>Reference Link</b></em>' attribute. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PAGEFLOW_ELEMENT__REFERENCE_LINK = 7; - - /** - * The number of structural features of the the '<em>Element</em>' - * class. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PAGEFLOW_ELEMENT_FEATURE_COUNT = 8; - - /** - * The meta object id for the '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowImpl <em>Pageflow</em>}' - * class. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowImpl - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowPackageImpl#getPageflow() - * @generated - */ - int PAGEFLOW = 0; - - /** - * The feature id for the '<em><b>Name</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PAGEFLOW__NAME = PAGEFLOW_ELEMENT__NAME; - - /** - * The feature id for the '<em><b>Comment</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PAGEFLOW__COMMENT = PAGEFLOW_ELEMENT__COMMENT; - - /** - * The feature id for the '<em><b>X</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PAGEFLOW__X = PAGEFLOW_ELEMENT__X; - - /** - * The feature id for the '<em><b>Y</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PAGEFLOW__Y = PAGEFLOW_ELEMENT__Y; - - /** - * The feature id for the '<em><b>Width</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PAGEFLOW__WIDTH = PAGEFLOW_ELEMENT__WIDTH; - - /** - * The feature id for the '<em><b>Height</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PAGEFLOW__HEIGHT = PAGEFLOW_ELEMENT__HEIGHT; - - /** - * The feature id for the '<em><b>Id</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PAGEFLOW__ID = PAGEFLOW_ELEMENT__ID; - - /** - * The feature id for the '<em><b>Reference Link</b></em>' attribute. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PAGEFLOW__REFERENCE_LINK = PAGEFLOW_ELEMENT__REFERENCE_LINK; - - /** - * The feature id for the '<em><b>Nodes</b></em>' containment reference - * list. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PAGEFLOW__NODES = PAGEFLOW_ELEMENT_FEATURE_COUNT + 0; - - /** - * The feature id for the '<em><b>Links</b></em>' containment reference - * list. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PAGEFLOW__LINKS = PAGEFLOW_ELEMENT_FEATURE_COUNT + 1; - - /** - * The feature id for the '<em><b>Configfile</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PAGEFLOW__CONFIGFILE = PAGEFLOW_ELEMENT_FEATURE_COUNT + 2; - - /** - * The number of structural features of the the '<em>Pageflow</em>' - * class. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PAGEFLOW_FEATURE_COUNT = PAGEFLOW_ELEMENT_FEATURE_COUNT + 3; - - /** - * The meta object id for the '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowNodeImpl <em>Node</em>}' - * class. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowNodeImpl - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowPackageImpl#getPageflowNode() - * @generated - */ - int PAGEFLOW_NODE = 1; - - /** - * The feature id for the '<em><b>Name</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PAGEFLOW_NODE__NAME = PAGEFLOW_ELEMENT__NAME; - - /** - * The feature id for the '<em><b>Comment</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PAGEFLOW_NODE__COMMENT = PAGEFLOW_ELEMENT__COMMENT; - - /** - * The feature id for the '<em><b>X</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PAGEFLOW_NODE__X = PAGEFLOW_ELEMENT__X; - - /** - * The feature id for the '<em><b>Y</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PAGEFLOW_NODE__Y = PAGEFLOW_ELEMENT__Y; - - /** - * The feature id for the '<em><b>Width</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PAGEFLOW_NODE__WIDTH = PAGEFLOW_ELEMENT__WIDTH; - - /** - * The feature id for the '<em><b>Height</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PAGEFLOW_NODE__HEIGHT = PAGEFLOW_ELEMENT__HEIGHT; - - /** - * The feature id for the '<em><b>Id</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PAGEFLOW_NODE__ID = PAGEFLOW_ELEMENT__ID; - - /** - * The feature id for the '<em><b>Reference Link</b></em>' attribute. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PAGEFLOW_NODE__REFERENCE_LINK = PAGEFLOW_ELEMENT__REFERENCE_LINK; - - /** - * The feature id for the '<em><b>Pageflow</b></em>' container - * reference. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PAGEFLOW_NODE__PAGEFLOW = PAGEFLOW_ELEMENT_FEATURE_COUNT + 0; - - /** - * The feature id for the '<em><b>Outlinks</b></em>' reference list. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PAGEFLOW_NODE__OUTLINKS = PAGEFLOW_ELEMENT_FEATURE_COUNT + 1; - - /** - * The feature id for the '<em><b>Inlinks</b></em>' reference list. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PAGEFLOW_NODE__INLINKS = PAGEFLOW_ELEMENT_FEATURE_COUNT + 2; - - /** - * The number of structural features of the the '<em>Node</em>' class. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PAGEFLOW_NODE_FEATURE_COUNT = PAGEFLOW_ELEMENT_FEATURE_COUNT + 3; - - /** - * The meta object id for the '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowLinkImpl <em>PF Link</em>}' - * class. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowLinkImpl - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowPackageImpl#getPFLink() - * @generated - */ - int PF_LINK = 2; - - /** - * The feature id for the '<em><b>Name</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_LINK__NAME = PAGEFLOW_ELEMENT__NAME; - - /** - * The feature id for the '<em><b>Comment</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_LINK__COMMENT = PAGEFLOW_ELEMENT__COMMENT; - - /** - * The feature id for the '<em><b>X</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_LINK__X = PAGEFLOW_ELEMENT__X; - - /** - * The feature id for the '<em><b>Y</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_LINK__Y = PAGEFLOW_ELEMENT__Y; - - /** - * The feature id for the '<em><b>Width</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_LINK__WIDTH = PAGEFLOW_ELEMENT__WIDTH; - - /** - * The feature id for the '<em><b>Height</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_LINK__HEIGHT = PAGEFLOW_ELEMENT__HEIGHT; - - /** - * The feature id for the '<em><b>Id</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_LINK__ID = PAGEFLOW_ELEMENT__ID; - - /** - * The feature id for the '<em><b>Reference Link</b></em>' attribute. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_LINK__REFERENCE_LINK = PAGEFLOW_ELEMENT__REFERENCE_LINK; - - /** - * The feature id for the '<em><b>Pageflow</b></em>' container - * reference. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_LINK__PAGEFLOW = PAGEFLOW_ELEMENT_FEATURE_COUNT + 0; - - /** - * The feature id for the '<em><b>Target</b></em>' reference. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_LINK__TARGET = PAGEFLOW_ELEMENT_FEATURE_COUNT + 1; - - /** - * The feature id for the '<em><b>Source</b></em>' reference. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_LINK__SOURCE = PAGEFLOW_ELEMENT_FEATURE_COUNT + 2; - - /** - * The feature id for the '<em><b>Outcome</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_LINK__OUTCOME = PAGEFLOW_ELEMENT_FEATURE_COUNT + 3; - - /** - * The feature id for the '<em><b>Redirect</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_LINK__REDIRECT = PAGEFLOW_ELEMENT_FEATURE_COUNT + 4; - - /** - * The feature id for the '<em><b>Bend Points</b></em>' containment - * reference list. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_LINK__BEND_POINTS = PAGEFLOW_ELEMENT_FEATURE_COUNT + 5; - - /** - * The feature id for the '<em><b>Smallicon</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_LINK__SMALLICON = PAGEFLOW_ELEMENT_FEATURE_COUNT + 6; - - /** - * The feature id for the '<em><b>Largeicon</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_LINK__LARGEICON = PAGEFLOW_ELEMENT_FEATURE_COUNT + 7; - - /** - * The feature id for the '<em><b>Fromaction</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_LINK__FROMACTION = PAGEFLOW_ELEMENT_FEATURE_COUNT + 8; - - /** - * The number of structural features of the the '<em>PF Link</em>' - * class. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_LINK_FEATURE_COUNT = PAGEFLOW_ELEMENT_FEATURE_COUNT + 9; - - /** - * The meta object id for the '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowPageImpl <em>PF Page</em>}' - * class. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowPageImpl - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowPackageImpl#getPFPage() - * @generated - */ - int PF_PAGE = 5; - - /** - * The feature id for the '<em><b>Name</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_PAGE__NAME = PAGEFLOW_NODE__NAME; - - /** - * The feature id for the '<em><b>Comment</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_PAGE__COMMENT = PAGEFLOW_NODE__COMMENT; - - /** - * The feature id for the '<em><b>X</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_PAGE__X = PAGEFLOW_NODE__X; - - /** - * The feature id for the '<em><b>Y</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_PAGE__Y = PAGEFLOW_NODE__Y; - - /** - * The feature id for the '<em><b>Width</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_PAGE__WIDTH = PAGEFLOW_NODE__WIDTH; - - /** - * The feature id for the '<em><b>Height</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_PAGE__HEIGHT = PAGEFLOW_NODE__HEIGHT; - - /** - * The feature id for the '<em><b>Id</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_PAGE__ID = PAGEFLOW_NODE__ID; - - /** - * The feature id for the '<em><b>Pageflow</b></em>' container - * reference. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_PAGE__PAGEFLOW = PAGEFLOW_NODE__PAGEFLOW; - - /** - * The feature id for the '<em><b>Outlinks</b></em>' reference list. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_PAGE__OUTLINKS = PAGEFLOW_NODE__OUTLINKS; - - /** - * The feature id for the '<em><b>Inlinks</b></em>' reference list. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_PAGE__INLINKS = PAGEFLOW_NODE__INLINKS; - - /** - * The feature id for the '<em><b>Path</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_PAGE__PATH = PAGEFLOW_NODE_FEATURE_COUNT + 0; - - /** - * The feature id for the '<em><b>Smallicon</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_PAGE__SMALLICON = PAGEFLOW_NODE_FEATURE_COUNT + 1; - - /** - * The feature id for the '<em><b>Largeicon</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_PAGE__LARGEICON = PAGEFLOW_NODE_FEATURE_COUNT + 2; - - /** - * The number of structural features of the the '<em>PF Page</em>' - * class. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_PAGE_FEATURE_COUNT = PAGEFLOW_NODE_FEATURE_COUNT + 3; - - /** - * The meta object id for the '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowLinkBendpointImpl <em>PF Link Bendpoint</em>}' - * class. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowLinkBendpointImpl - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowPackageImpl#getPFLinkBendpoint() - * @generated - */ - int PF_LINK_BENDPOINT = 8; - - /** - * The feature id for the '<em><b>D1 Width</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_LINK_BENDPOINT__D1_WIDTH = 0; - - /** - * The feature id for the '<em><b>D1 Height</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_LINK_BENDPOINT__D1_HEIGHT = 1; - - /** - * The feature id for the '<em><b>D2 Width</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_LINK_BENDPOINT__D2_WIDTH = 2; - - /** - * The feature id for the '<em><b>D2 Height</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_LINK_BENDPOINT__D2_HEIGHT = 3; - - /** - * The feature id for the '<em><b>Weight</b></em>' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_LINK_BENDPOINT__WEIGHT = 4; - - /** - * The feature id for the '<em><b>Link</b></em>' container reference. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_LINK_BENDPOINT__LINK = 5; - - /** - * The number of structural features of the the '<em>PF Link Bendpoint</em>' - * class. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - * @ordered - */ - int PF_LINK_BENDPOINT_FEATURE_COUNT = 6; - - /** - * Returns the meta object for class '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow <em>Pageflow</em>}'. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @return the meta object for class '<em>Pageflow</em>'. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow - * @generated - */ - EClass getPageflow(); - - /** - * Returns the meta object for the containment reference list '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow#getNodes <em>Nodes</em>}'. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @return the meta object for the containment reference list '<em>Nodes</em>'. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow#getNodes() - * @see #getPageflow() - * @generated - */ - EReference getPageflow_Nodes(); - - /** - * Returns the meta object for the containment reference list '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow#getLinks <em>Links</em>}'. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @return the meta object for the containment reference list '<em>Links</em>'. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow#getLinks() - * @see #getPageflow() - * @generated - */ - EReference getPageflow_Links(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow#getConfigfile <em>Configfile</em>}'. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @return the meta object for the attribute '<em>Configfile</em>'. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow#getConfigfile() - * @see #getPageflow() - * @generated - */ - EAttribute getPageflow_Configfile(); - - /** - * Returns the meta object for class '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode <em>Node</em>}'. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @return the meta object for class '<em>Node</em>'. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode - * @generated - */ - EClass getPageflowNode(); - - /** - * Returns the meta object for the container reference '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode#getPageflow <em>Pageflow</em>}'. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @return the meta object for the container reference '<em>Pageflow</em>'. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode#getPageflow() - * @see #getPageflowNode() - * @generated - */ - EReference getPageflowNode_Pageflow(); - - /** - * Returns the meta object for the reference list '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode#getOutlinks <em>Outlinks</em>}'. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @return the meta object for the reference list '<em>Outlinks</em>'. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode#getOutlinks() - * @see #getPageflowNode() - * @generated - */ - EReference getPageflowNode_Outlinks(); - - /** - * Returns the meta object for the reference list '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode#getInlinks <em>Inlinks</em>}'. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @return the meta object for the reference list '<em>Inlinks</em>'. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode#getInlinks() - * @see #getPageflowNode() - * @generated - */ - EReference getPageflowNode_Inlinks(); - - /** - * Returns the meta object for class '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink <em>PF Link</em>}'. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @return the meta object for class '<em>PF Link</em>'. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink - * @generated - */ - EClass getPFLink(); - - /** - * Returns the meta object for the container reference '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#getPageflow <em>Pageflow</em>}'. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @return the meta object for the container reference '<em>Pageflow</em>'. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#getPageflow() - * @see #getPFLink() - * @generated - */ - EReference getPFLink_Pageflow(); - - /** - * Returns the meta object for the reference '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#getTarget <em>Target</em>}'. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @return the meta object for the reference '<em>Target</em>'. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#getTarget() - * @see #getPFLink() - * @generated - */ - EReference getPFLink_Target(); - - /** - * Returns the meta object for the reference '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#getSource <em>Source</em>}'. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @return the meta object for the reference '<em>Source</em>'. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#getSource() - * @see #getPFLink() - * @generated - */ - EReference getPFLink_Source(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#getOutcome <em>Outcome</em>}'. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @return the meta object for the attribute '<em>Outcome</em>'. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#getOutcome() - * @see #getPFLink() - * @generated - */ - EAttribute getPFLink_Outcome(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#getOutcome <em>Outcome</em>}'. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @return the meta object for the attribute '<em>Outcome</em>'. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#getOutcome() - * @see #getPFLink() - * @generated - */ - EAttribute getPFLink_Fromaction(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#isRedirect <em>Redirect</em>}'. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @return the meta object for the attribute '<em>Redirect</em>'. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#isRedirect() - * @see #getPFLink() - * @generated - */ - EAttribute getPFLink_Redirect(); - - /** - * Returns the meta object for the containment reference list '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#getBendPoints <em>Bend Points</em>}'. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @return the meta object for the containment reference list '<em>Bend Points</em>'. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink#getBendPoints() - * @see #getPFLink() - * @generated - */ - EReference getPFLink_BendPoints(); - - /** - * Returns the meta object for class '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement <em>Element</em>}'. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @return the meta object for class '<em>Element</em>'. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement - * @generated - */ - EClass getPageflowElement(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement#getName <em>Name</em>}'. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @return the meta object for the attribute '<em>Name</em>'. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement#getName() - * @see #getPageflowElement() - * @generated - */ - EAttribute getPageflowElement_Name(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement#getComment <em>Comment</em>}'. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @return the meta object for the attribute '<em>Comment</em>'. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement#getComment() - * @see #getPageflowElement() - * @generated - */ - EAttribute getPageflowElement_Comment(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement#getX <em>X</em>}'. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @return the meta object for the attribute '<em>X</em>'. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement#getX() - * @see #getPageflowElement() - * @generated - */ - EAttribute getPageflowElement_X(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement#getY <em>Y</em>}'. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @return the meta object for the attribute '<em>Y</em>'. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement#getY() - * @see #getPageflowElement() - * @generated - */ - EAttribute getPageflowElement_Y(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement#getWidth <em>Width</em>}'. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @return the meta object for the attribute '<em>Width</em>'. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement#getWidth() - * @see #getPageflowElement() - * @generated - */ - EAttribute getPageflowElement_Width(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement#getHeight <em>Height</em>}'. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @return the meta object for the attribute '<em>Height</em>'. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement#getHeight() - * @see #getPageflowElement() - * @generated - */ - EAttribute getPageflowElement_Height(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement#getId <em>Id</em>}'. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @return the meta object for the attribute '<em>Id</em>'. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement#getId() - * @see #getPageflowElement() - * @generated - */ - EAttribute getPageflowElement_Id(); - - /** - * Returns the meta object for class '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage <em>PF Page</em>}'. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @return the meta object for class '<em>PF Page</em>'. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage - * @generated - */ - EClass getPFPage(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage#getPath <em>Path</em>}'. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @return the meta object for the attribute '<em>Path</em>'. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage#getPath() - * @see #getPFPage() - * @generated - */ - EAttribute getPFPage_Path(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage#getSmallicon <em>Smallicon</em>}'. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @return the meta object for the attribute '<em>Smallicon</em>'. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage#getSmallicon() - * @see #getPFPage() - * @generated - */ - EAttribute getPFPage_Smallicon(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage#getLargeicon <em>Largeicon</em>}'. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @return the meta object for the attribute '<em>Largeicon</em>'. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage#getLargeicon() - * @see #getPFPage() - * @generated - */ - EAttribute getPFPage_Largeicon(); - - /** - * Returns the meta object for class '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint <em>PF Link Bendpoint</em>}'. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @return the meta object for class '<em>PF Link Bendpoint</em>'. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint - * @generated - */ - EClass getPFLinkBendpoint(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint#getD1Width <em>D1 Width</em>}'. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @return the meta object for the attribute '<em>D1 Width</em>'. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint#getD1Width() - * @see #getPFLinkBendpoint() - * @generated - */ - EAttribute getPFLinkBendpoint_D1Width(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint#getD1Height <em>D1 Height</em>}'. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @return the meta object for the attribute '<em>D1 Height</em>'. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint#getD1Height() - * @see #getPFLinkBendpoint() - * @generated - */ - EAttribute getPFLinkBendpoint_D1Height(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint#getD2Width <em>D2 Width</em>}'. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @return the meta object for the attribute '<em>D2 Width</em>'. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint#getD2Width() - * @see #getPFLinkBendpoint() - * @generated - */ - EAttribute getPFLinkBendpoint_D2Width(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint#getD2Height <em>D2 Height</em>}'. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @return the meta object for the attribute '<em>D2 Height</em>'. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint#getD2Height() - * @see #getPFLinkBendpoint() - * @generated - */ - EAttribute getPFLinkBendpoint_D2Height(); - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint#getWeight <em>Weight</em>}'. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @return the meta object for the attribute '<em>Weight</em>'. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint#getWeight() - * @see #getPFLinkBendpoint() - * @generated - */ - EAttribute getPFLinkBendpoint_Weight(); - - /** - * Returns the meta object for the container reference '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint#getLink <em>Link</em>}'. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @return the meta object for the container reference '<em>Link</em>'. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint#getLink() - * @see #getPFLinkBendpoint() - * @generated - */ - EReference getPFLinkBendpoint_Link(); - - /** - * Returns the factory that creates the instances of the model. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @return the factory that creates the instances of the model. - * @generated - */ - PageflowFactory getPageflowFactory(); - -} -// PageflowPackage diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/PageflowPage.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/PageflowPage.java deleted file mode 100644 index b6cecb55e..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/PageflowPage.java +++ /dev/null @@ -1,117 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.model; - -/** - * <!-- begin-user-doc --> A representation of the model object '<em><b>PF Page</b></em>'. - * <!-- end-user-doc --> - * - * <p> - * The following features are supported: - * <ul> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage#getPath <em>Path</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage#getSmallicon <em>Smallicon</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage#getLargeicon <em>Largeicon</em>}</li> - * </ul> - * </p> - * - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage#getPFPage() - * @model - * @generated - */ -public interface PageflowPage extends PageflowNode { - /** - * Returns the value of the '<em><b>Path</b></em>' attribute. <!-- - * begin-user-doc --> - * <p> - * If the meaning of the '<em>Path</em>' attribute isn't clear, there - * really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * - * @return the value of the '<em>Path</em>' attribute. - * @see #setPath(String) - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage#getPFPage_Path() - * @model - * @generated - */ - String getPath(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage#getPath <em>Path</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @param value - * the new value of the '<em>Path</em>' attribute. - * @see #getPath() - * @generated - */ - void setPath(String value); - - /** - * Returns the value of the '<em><b>Smallicon</b></em>' attribute. <!-- - * begin-user-doc --> - * <p> - * If the meaning of the '<em>Smallicon</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * - * @return the value of the '<em>Smallicon</em>' attribute. - * @see #setSmallicon(String) - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage#getPFPage_Smallicon() - * @model - * @generated - */ - String getSmallicon(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage#getSmallicon <em>Smallicon</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @param value - * the new value of the '<em>Smallicon</em>' attribute. - * @see #getSmallicon() - * @generated - */ - void setSmallicon(String value); - - /** - * Returns the value of the '<em><b>Largeicon</b></em>' attribute. <!-- - * begin-user-doc --> - * <p> - * If the meaning of the '<em>Largeicon</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * - * @return the value of the '<em>Largeicon</em>' attribute. - * @see #setLargeicon(String) - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage#getPFPage_Largeicon() - * @model - * @generated - */ - String getLargeicon(); - - /** - * Sets the value of the '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage#getLargeicon <em>Largeicon</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @param value - * the new value of the '<em>Largeicon</em>' attribute. - * @see #getLargeicon() - * @generated - */ - void setLargeicon(String value); - -} -// PFPage diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/LinkReferenceElement.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/LinkReferenceElement.java deleted file mode 100644 index efff345e1..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/LinkReferenceElement.java +++ /dev/null @@ -1,269 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl; - -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory; -import org.eclipse.jst.jsf.facesconfig.emf.FromActionType; -import org.eclipse.jst.jsf.facesconfig.emf.FromOutcomeType; -import org.eclipse.jst.jsf.facesconfig.emf.IconType; -import org.eclipse.jst.jsf.facesconfig.emf.LargeIconType; -import org.eclipse.jst.jsf.facesconfig.emf.NavigationCaseType; -import org.eclipse.jst.jsf.facesconfig.emf.RedirectType; -import org.eclipse.jst.jsf.facesconfig.emf.SmallIconType; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.synchronization.TransformUtil; - -/** - * The reference element represents a mapping from pageflow link to a navigation - * case. - * - * @author hmeng - */ - -public class LinkReferenceElement extends ReferenceElement { - - public void add(EObject object) { - Assert.isTrue(object instanceof NavigationCaseType); - clear(); - super.add(object); - } - - public LinkReferenceElement(PageflowElement pageflowElement) { - super(pageflowElement); - // TODO Auto-generated constructor stub - } - - public LinkReferenceElement(PageflowElement pageflowElement, - EObject facesConfigObject) { - super(pageflowElement, facesConfigObject); - // TODO Auto-generated constructor stub - } - - public void update() { - for (Iterator nodes = getData().iterator(); nodes.hasNext();) { - Object next = nodes.next(); - if (!TransformUtil.isValidFacesConfigElement((EObject) next)) { - nodes.remove(); - } - } - } - - public Object get(int eFeature) { - Object result = null; - switch (eFeature) { - case PageflowPackage.PF_LINK__COMMENT: - break; - case PageflowPackage.PF_LINK__OUTCOME: - if (!isEmpty()) { - FromOutcomeType outcome = ((NavigationCaseType) getData() - .get(0)).getFromOutcome(); - if (outcome != null) { - result = outcome.getTextContent(); - } - } - break; - case PageflowPackage.PF_LINK__NAME: - break; - case PageflowPackage.PF_LINK__REDIRECT: - result = new Boolean(false); - if (!isEmpty()) { - RedirectType outcome = ((NavigationCaseType) getData().get(0)) - .getRedirect(); - if (outcome != null) { - result = new Boolean(true); - } - } - break; - - case PageflowPackage.PF_LINK__FROMACTION: - if (!isEmpty()) { - FromActionType fromActionType = ((NavigationCaseType) getData() - .get(0)).getFromAction(); - if (fromActionType != null) { - result = fromActionType.getTextContent(); - } - } - break; - case PageflowPackage.PF_LINK__SMALLICON: - if (!isEmpty()) { - List icons = ((NavigationCaseType) getData().get(0)).getIcon(); - if (icons.size() > 0) { - result = ((IconType) icons.get(0)).getSmallIcon() != null ? ((IconType) icons - .get(0)).getSmallIcon().getTextContent() - : null; - } - } - break; - case PageflowPackage.PF_LINK__LARGEICON: - if (!isEmpty()) { - List icons = ((NavigationCaseType) getData().get(0)).getIcon(); - if (icons.size() > 0) { - result = ((IconType) icons.get(0)).getLargeIcon() != null ? ((IconType) icons - .get(0)).getLargeIcon().getTextContent() - : null; - } - } - break; - } - return result; - } - - public void set(EStructuralFeature eFeature, Object newVal) { - switch (eFeature.getFeatureID()) { - case PageflowPackage.PF_LINK__COMMENT: - break; - case PageflowPackage.PF_LINK__OUTCOME: { - FromOutcomeType oldOutcome = null; - FromOutcomeType newOutcome = null; - String newValue = (String) newVal; - if (!isEmpty()) { - oldOutcome = ((NavigationCaseType) getData().get(0)) - .getFromOutcome(); - if (newValue == null || newValue.length() == 0) { - ((NavigationCaseType) getData().get(0)) - .setFromOutcome(null); - } else { - if (oldOutcome == null) { - newOutcome = FacesConfigFactory.eINSTANCE - .createFromOutcomeType(); - newOutcome.setTextContent(newValue); - ((NavigationCaseType) getData().get(0)) - .setFromOutcome(newOutcome); - } else { - oldOutcome.setTextContent(newValue); - } - } - } - break; - } - case PageflowPackage.PF_LINK__NAME: - break; - case PageflowPackage.PF_LINK__REDIRECT: - RedirectType redirect = null; - RedirectType oldRedirect = null; - boolean newRedirect = ((Boolean) newVal).booleanValue(); - if (!isEmpty()) { - oldRedirect = ((NavigationCaseType) getData().get(0)) - .getRedirect(); - if (!newRedirect) { - redirect = null; - } else { - if (oldRedirect == null) { - redirect = FacesConfigFactory.eINSTANCE - .createRedirectType(); - } - } - ((NavigationCaseType) getData().get(0)).setRedirect(redirect); - } - break; - case PageflowPackage.PF_LINK__FROMACTION: - FromActionType oldFromActionType, - newFromActionType; - String newFromaction = (String) newVal; - if (!isEmpty()) { - oldFromActionType = ((NavigationCaseType) getData().get(0)) - .getFromAction(); - if (newFromaction == null || newFromaction.length() == 0) { - ((NavigationCaseType) getData().get(0)).setFromAction(null); - } else { - if (oldFromActionType == null) { - newFromActionType = FacesConfigFactory.eINSTANCE - .createFromActionType(); - newFromActionType.setTextContent(newFromaction); - ((NavigationCaseType) getData().get(0)) - .setFromAction(newFromActionType); - } else { - oldFromActionType.setTextContent(newFromaction); - } - } - } - break; - case PageflowPackage.PF_LINK__SMALLICON: { - SmallIconType oldSmallicon = null; - SmallIconType newSmallIconType = null; - IconType icon = null; - String newValue = (String) newVal; - if (!isEmpty()) { - List icons = ((NavigationCaseType) getData().get(0)).getIcon(); - if (newValue == null || newValue.length() == 0) { - if (icons.size() > 0) { - if (((IconType) icons.get(0)).getSmallIcon() != null) { - ((IconType) icons.get(0)).setSmallIcon(null); - } - } - } else { - if (icons.size() == 0) { - icon = FacesConfigFactory.eINSTANCE.createIconType(); - newSmallIconType = FacesConfigFactory.eINSTANCE - .createSmallIconType(); - newSmallIconType.setTextContent(newValue); - icon.setSmallIcon(newSmallIconType); - icons.add(icon); - } else if (((IconType) icons.get(0)).getSmallIcon() == null) { - newSmallIconType = FacesConfigFactory.eINSTANCE - .createSmallIconType(); - newSmallIconType.setTextContent(newValue); - icon = ((IconType) icons.get(0)); - icon.setSmallIcon(newSmallIconType); - } else { - oldSmallicon = ((IconType) icons.get(0)).getSmallIcon(); - oldSmallicon.setTextContent(newValue); - } - } - } - break; - } - case PageflowPackage.PF_LINK__LARGEICON: { - String newValue = (String) newVal; - LargeIconType oldLargeIcon = null; - LargeIconType newLargeIconType = null; - IconType icon = null; - if (!isEmpty()) { - List icons = ((NavigationCaseType) getData().get(0)).getIcon(); - if (newValue == null || newValue.length() == 0) { - if (icons.size() > 0) { - if (((IconType) icons.get(0)).getLargeIcon() != null) { - ((IconType) icons.get(0)).setLargeIcon(null); - } - } - } else { - if (icons.size() == 0) { - icon = FacesConfigFactory.eINSTANCE.createIconType(); - newLargeIconType = FacesConfigFactory.eINSTANCE - .createLargeIconType(); - newLargeIconType.setTextContent(newValue); - icon.setLargeIcon(newLargeIconType); - icons.add(icon); - } else if (((IconType) icons.get(0)).getLargeIcon() == null) { - newLargeIconType = FacesConfigFactory.eINSTANCE - .createLargeIconType(); - newLargeIconType.setTextContent(newValue); - icon = ((IconType) icons.get(0)); - icon.setLargeIcon(newLargeIconType); - } else { - oldLargeIcon = ((IconType) icons.get(0)).getLargeIcon(); - oldLargeIcon.setTextContent(newValue); - } - } - } - break; - } - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageReferenceElement.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageReferenceElement.java deleted file mode 100644 index e78cf0910..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageReferenceElement.java +++ /dev/null @@ -1,392 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl; - -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.jst.jsf.facesconfig.emf.DescriptionType; -import org.eclipse.jst.jsf.facesconfig.emf.DisplayNameType; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory; -import org.eclipse.jst.jsf.facesconfig.emf.FromViewIdType; -import org.eclipse.jst.jsf.facesconfig.emf.IconType; -import org.eclipse.jst.jsf.facesconfig.emf.LargeIconType; -import org.eclipse.jst.jsf.facesconfig.emf.NavigationCaseType; -import org.eclipse.jst.jsf.facesconfig.emf.NavigationRuleType; -import org.eclipse.jst.jsf.facesconfig.emf.SmallIconType; -import org.eclipse.jst.jsf.facesconfig.emf.ToViewIdType; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.synchronization.FC2PFTransformer; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.synchronization.TransformUtil; - -/** - * The reference element represents a mapping from pageflow page to one or more - * navigation rules/cases's view IDs (fromViewID or toViewID). - * - * @author hmeng - */ - -public class PageReferenceElement extends ReferenceElement { - - public PageReferenceElement(PageflowElement pageflowElement) { - super(pageflowElement); - // TODO Auto-generated constructor stub - } - - public PageReferenceElement(PageflowElement pageflowElement, - EObject facesConfigObject) { - super(pageflowElement, facesConfigObject); - // TODO Auto-generated constructor stub - } - - public void add(EObject object) { - Assert.isTrue(object instanceof FromViewIdType - || object instanceof ToViewIdType); - super.add(object); - } - - public void update() { - outer: for (Iterator nodes = getData().iterator(); nodes.hasNext();) { - Object next = nodes.next(); - if (next instanceof FromViewIdType) { - if (!TransformUtil.isValidFacesConfigElement((EObject) next)) { - nodes.remove(); - continue; - } - List links = ((PageflowPage) pageflowElement).getOutlinks(); - for (int i = 0; i < links.size(); i++) { - PageflowLink link = (PageflowLink) links.get(i); - if (!link.getFCElements().isEmpty() - && TransformUtil - .isValidFacesConfigElement((NavigationCaseType) ((PageflowLink) links - .get(i)).getFCElements().getData() - .get(0))) { - NavigationRuleType rule = (NavigationRuleType) ((NavigationCaseType) ((PageflowLink) links - .get(i)).getFCElements().getData().get(0)) - .eContainer(); - if (rule == null || rule.getFromViewId() == next) { - // There navigation case - // matching this end. - continue outer; - } - } - } - // No case contains this end. - nodes.remove(); - } else if (next instanceof ToViewIdType) { - if (!TransformUtil.isValidFacesConfigElement((EObject) next)) { - nodes.remove(); - continue; - } - // Verify this is case end. - List links = ((PageflowPage) pageflowElement).getInlinks(); - for (int i = 0; i < links.size(); i++) { - PageflowLink link = (PageflowLink) links.get(i); - if (!link.getFCElements().isEmpty() - && TransformUtil - .isValidFacesConfigElement((NavigationCaseType) link - .getFCElements().getData().get(0))) { - if (((NavigationCaseType) ((PageflowLink) links.get(i)) - .getFCElements().getData().get(0)) - .getToViewId() == next) { - // There navigation case - // matching this end. - continue outer; - } - } - } - // No case contains this end. - nodes.remove(); - } - } - } - - public Object get(int eFeature) { - Object result = null; - switch (eFeature) { - case PageflowPackage.PF_PAGE__COMMENT: - if (!isEmpty()) { - for (int i = 0, n = getData().size(); i < n; i++) { - NavigationRuleType rule = null; - if ((rule = resolveRuleFromFCElement(getData().get(i))) != null) { - List descriptions = rule.getDescription(); - if (descriptions.size() > 0) { - result = ((DescriptionType) descriptions.get(0)) - .getTextContent(); - break; - } - } - } - } - break; - case PageflowPackage.PF_PAGE__LARGEICON: - if (!isEmpty()) { - for (int i = 0, n = getData().size(); i < n; i++) { - NavigationRuleType rule = null; - if ((rule = resolveRuleFromFCElement(getData().get(i))) != null) { - List icons = rule.getIcon(); - if (icons.size() > 0) { - result = ((IconType) icons.get(0)).getLargeIcon() != null ? ((IconType) icons - .get(0)).getLargeIcon().getTextContent() - : null; - break; - } - } - } - } - break; - case PageflowPackage.PF_PAGE__NAME: - // To see if it is in navigation rule. - if (!isEmpty() && !isEndOnly()) { - for (int i = 0, n = getData().size(); i < n; i++) { - NavigationRuleType rule = null; - if ((rule = resolveRuleFromFCElement(getData().get(i))) != null) { - List displaynames = rule.getDisplayName(); - if (displaynames.size() > 0) { - result = ((DisplayNameType) displaynames.get(0)) - .getTextContent(); - break; - } - } - } - } - break; - case PageflowPackage.PF_PAGE__PATH: - if (!isEmpty()) { - for (int i = 0, n = getData().size(); i < n; i++) { - if (getData().get(i) instanceof FromViewIdType) { - result = ((FromViewIdType) getData().get(i)) - .getTextContent(); - break; - } - } - if (result == null && getData().get(0) instanceof ToViewIdType) { - result = ((ToViewIdType) getData().get(0)).getTextContent(); - } - } - break; - case PageflowPackage.PF_PAGE__SMALLICON: - if (!isEmpty()) { - for (int i = 0, n = getData().size(); i < n; i++) { - NavigationRuleType rule = null; - if ((rule = resolveRuleFromFCElement(getData().get(i))) != null) { - List icons = rule.getIcon(); - if (icons.size() > 0) { - result = ((IconType) icons.get(0)).getSmallIcon() != null ? ((IconType) icons - .get(0)).getSmallIcon().getTextContent() - : null; - break; - } - } - } - } - break; - } - return result; - } - - public NavigationRuleType resolveRuleFromFCElement(Object object) { - if (object instanceof FromViewIdType) { - return (NavigationRuleType) ((FromViewIdType) object).eContainer(); - } - return null; - } - - public NavigationRuleType resolveRuleFromPFElement(Object object) { - if (object instanceof PageflowLink) { - NavigationCaseType caseType = (NavigationCaseType) ((PageflowLink) object) - .getFCElements().getData().get(0); - return (NavigationRuleType) caseType.eContainer(); - } - return null; - } - - public void set(EStructuralFeature eFeature, Object newVal) { - switch (eFeature.getFeatureID()) { - case PageflowPackage.PF_PAGE__COMMENT: { - DescriptionType description = null; - String newValue = (String) newVal; - if (!isEmpty()) { - for (int i = 0, n = getData().size(); i < n; i++) { - NavigationRuleType rule = null; - if ((rule = resolveRuleFromFCElement(getData().get(i))) != null) { - rule.getDescription().clear(); - description = FacesConfigFactory.eINSTANCE - .createDescriptionType(); - description.setTextContent(newValue); - rule.getDescription().add(description); - } - } - } - break; - } - case PageflowPackage.PF_PAGE__LARGEICON: { - LargeIconType oldLargeIcon = null; - LargeIconType newLargeIconType = null; - IconType icon = null; - String newValue = (String) newVal; - if (!isEmpty()) { - for (int i = 0, n = getData().size(); i < n; i++) { - NavigationRuleType rule = null; - if ((rule = resolveRuleFromFCElement(getData().get(i))) != null) { - List icons = rule.getIcon(); - if (newValue == null || newValue.length() == 0) { - if (icons.size() > 0) { - if (((IconType) icons.get(0)).getLargeIcon() != null) { - ((IconType) icons.get(0)) - .setLargeIcon(null); - } - } - } else { - if (icons.size() == 0) { - icon = FacesConfigFactory.eINSTANCE - .createIconType(); - newLargeIconType = FacesConfigFactory.eINSTANCE - .createLargeIconType(); - newLargeIconType.setTextContent(newValue); - icon.setLargeIcon(newLargeIconType); - icons.add(icon); - } else if (((IconType) icons.get(0)).getLargeIcon() == null) { - newLargeIconType = FacesConfigFactory.eINSTANCE - .createLargeIconType(); - newLargeIconType.setTextContent(newValue); - icon = ((IconType) icons.get(0)); - icon.setLargeIcon(newLargeIconType); - } else { - oldLargeIcon = ((IconType) icons.get(0)) - .getLargeIcon(); - oldLargeIcon.setTextContent(newValue); - } - } - } - } - } - break; - } - case PageflowPackage.PF_PAGE__NAME: - DisplayNameType newDisplayNameType = null; - String newName = (String) newVal; - if (!isEmpty()) { - for (int i = 0, n = getData().size(); i < n; i++) { - NavigationRuleType rule = null; - if ((rule = resolveRuleFromFCElement(getData().get(i))) != null) { - rule.getDisplayName().clear(); - if (newName != null && newName.length() > 0) { - newDisplayNameType = FacesConfigFactory.eINSTANCE - .createDisplayNameType(); - newDisplayNameType.setTextContent(newName); - rule.getDisplayName().add(newDisplayNameType); - } - } - } - } - break; - case PageflowPackage.PF_PAGE__PATH: { - Object oldPath = null; - Object newPath = null; - String newValue = (String) newVal; - if (!isEmpty()) { - for (int i = 0, n = getData().size(); i < n; i++) { - if (getData().get(i) instanceof FromViewIdType) { - oldPath = getData().get(i); - ((FromViewIdType) oldPath).setTextContent(newValue); - } else if (getData().get(i) instanceof ToViewIdType) { - oldPath = getData().get(i); - ((ToViewIdType) oldPath).setTextContent(newValue); - } - } - } - // Create new fromViewID or toViewID node as needed. - else if (newValue != null && !"*".equals(newValue)) { - if (((PageflowPage) pageflowElement).getOutlinks().size() > 0) { - List links = ((PageflowPage) pageflowElement).getOutlinks(); - for (int i = 0, n = links.size(); i < n; i++) { - PageflowLink link = (PageflowLink) links.get(i); - NavigationRuleType rule = resolveRuleFromPFElement(link); - newPath = FC2PFTransformer.createRLFromViewID(newValue); - rule.setFromViewId((FromViewIdType) newPath); - add((EObject) newPath); - } - links = ((PageflowPage) pageflowElement).getInlinks(); - for (int i = 0, n = links.size(); i < n; i++) { - PageflowLink link = (PageflowLink) links.get(i); - NavigationCaseType caseType = (NavigationCaseType) link - .getFCElements().getData().get(0); - newPath = FC2PFTransformer.createFCToViewID(newValue); - caseType.setToViewId((ToViewIdType) newPath); - add((EObject) newPath); - } - } - } - break; - } - case PageflowPackage.PF_PAGE__SMALLICON: { - SmallIconType oldSmallicon = null; - SmallIconType newSmallIconType = null; - IconType icon = null; - String newValue = (String) newVal; - if (!isEmpty()) { - for (int i = 0, n = getData().size(); i < n; i++) { - NavigationRuleType rule = null; - if ((rule = resolveRuleFromFCElement(getData().get(i))) != null) { - List icons = rule.getIcon(); - if (newValue == null || newValue.length() == 0) { - if (icons.size() > 0) { - if (((IconType) icons.get(0)).getSmallIcon() != null) { - ((IconType) icons.get(0)) - .setSmallIcon(null); - } - } - } else { - if (icons.size() == 0) { - icon = FacesConfigFactory.eINSTANCE - .createIconType(); - newSmallIconType = FacesConfigFactory.eINSTANCE - .createSmallIconType(); - newSmallIconType.setTextContent(newValue); - icon.setSmallIcon(newSmallIconType); - icons.add(icon); - } else if (((IconType) icons.get(0)).getSmallIcon() == null) { - newSmallIconType = FacesConfigFactory.eINSTANCE - .createSmallIconType(); - newSmallIconType.setTextContent(newValue); - icon = ((IconType) icons.get(0)); - icon.setSmallIcon(newSmallIconType); - } else { - oldSmallicon = ((IconType) icons.get(0)) - .getSmallIcon(); - oldSmallicon.setTextContent(newValue); - } - } - } - } - } - break; - } - } - } - - public boolean isEndOnly() { - for (int i = 0, n = getData().size(); i < n; i++) { - if (getData().get(i) instanceof FromViewIdType) { - return false; - } - } - return true; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowElementImpl.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowElementImpl.java deleted file mode 100644 index eb7c4b86f..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowElementImpl.java +++ /dev/null @@ -1,607 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.EObjectImpl; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.synchronization.TransformUtil; - -/** - * <!-- begin-user-doc --> An implementation of the model object '<em><b>Element</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * <ul> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowElementImpl#getName <em>Name</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowElementImpl#getComment <em>Comment</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowElementImpl#getX <em>X</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowElementImpl#getY <em>Y</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowElementImpl#getWidth <em>Width</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowElementImpl#getHeight <em>Height</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowElementImpl#getId <em>Id</em>}</li> - * </ul> - * </p> - * - * @generated - */ -public abstract class PageflowElementImpl extends EObjectImpl implements - PageflowElement { - protected static final String idPrefix = "pf"; - - protected String id; - - protected static int counter = 0; - - protected ReferenceElement refElement; - - /** - * The default value of the '{@link #getName() <em>Name</em>}' attribute. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see #getName() - * @generated - * @ordered - */ - protected static final String NAME_EDEFAULT = "unnamed"; - - /** - * The cached value of the '{@link #getName() <em>Name</em>}' attribute. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see #getName() - * @generated - * @ordered - */ - protected String name = NAME_EDEFAULT; - - /** - * The default value of the '{@link #getComment() <em>Comment</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see #getComment() - * @generated - * @ordered - */ - protected static final String COMMENT_EDEFAULT = null; - - /** - * The cached value of the '{@link #getComment() <em>Comment</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see #getComment() - * @generated - * @ordered - */ - protected String comment = COMMENT_EDEFAULT; - - /** - * The default value of the '{@link #getX() <em>X</em>}' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @see #getX() - * @generated - * @ordered - */ - protected static final int X_EDEFAULT = 0; - - /** - * The cached value of the '{@link #getX() <em>X</em>}' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @see #getX() - * @generated - * @ordered - */ - protected int x = X_EDEFAULT; - - /** - * The default value of the '{@link #getY() <em>Y</em>}' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @see #getY() - * @generated - * @ordered - */ - protected static final int Y_EDEFAULT = 0; - - /** - * The cached value of the '{@link #getY() <em>Y</em>}' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @see #getY() - * @generated - * @ordered - */ - protected int y = Y_EDEFAULT; - - /** - * The default value of the '{@link #getWidth() <em>Width</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see #getWidth() - * @generated - * @ordered - */ - protected static final int WIDTH_EDEFAULT = -1; - - /** - * The cached value of the '{@link #getWidth() <em>Width</em>}' attribute. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see #getWidth() - * @generated - * @ordered - */ - protected int width = WIDTH_EDEFAULT; - - /** - * The default value of the '{@link #getHeight() <em>Height</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see #getHeight() - * @generated - * @ordered - */ - protected static final int HEIGHT_EDEFAULT = -1; - - /** - * The default value of the '{@link #getReferenceLink() <em>Reference Link</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see #getReferenceLink() - * @generated - * @ordered - */ - protected static final String REFERENCE_LINK_EDEFAULT = ""; - - /** - * The cached value of the '{@link #getReferenceLink() <em>Reference Link</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see #getReferenceLink() - * @generated - * @ordered - */ - protected String referenceLink = REFERENCE_LINK_EDEFAULT; - - /** - * The cached value of the '{@link #getHeight() <em>Height</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see #getHeight() - * @generated - * @ordered - */ - protected int height = HEIGHT_EDEFAULT; - - /** - * The default value of the '{@link #getId() <em>Id</em>}' attribute. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @see #getId() - * @generated - * @ordered - */ - protected static final String ID_EDEFAULT = null; - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - protected PageflowElementImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - protected EClass eStaticClass() { - return PageflowPackage.eINSTANCE.getPageflowElement(); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public String getName() { - return name == null || name.length() == 0 ? NAME_EDEFAULT : name; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public void setName(String newName) { - String oldName = name; - name = newName; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, - PageflowPackage.PAGEFLOW_ELEMENT__NAME, oldName, name)); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public String getComment() { - return comment; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public void setComment(String newComment) { - String oldComment = comment; - comment = newComment; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, - PageflowPackage.PAGEFLOW_ELEMENT__COMMENT, oldComment, - comment)); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public int getX() { - return x; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public void setX(int newX) { - int oldX = x; - x = newX; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, - PageflowPackage.PAGEFLOW_ELEMENT__X, oldX, x)); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public int getY() { - return y; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public void setY(int newY) { - int oldY = y; - y = newY; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, - PageflowPackage.PAGEFLOW_ELEMENT__Y, oldY, y)); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public int getWidth() { - return width; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public void setWidth(int newWidth) { - int oldWidth = width; - width = newWidth; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, - PageflowPackage.PAGEFLOW_ELEMENT__WIDTH, oldWidth, width)); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public int getHeight() { - return height; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public void setHeight(int newHeight) { - int oldHeight = height; - height = newHeight; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, - PageflowPackage.PAGEFLOW_ELEMENT__HEIGHT, oldHeight, height)); - } - - /** - * Generate (and cache) an id as needed - * - * @generated NOT - */ - public String getId() { - if (id == null) { - id = generateId(); - } - return id; - } - - /** - * Generate a random id based on the current time - * - * @return the generated id - * - * @generated NOT - */ - public synchronized String generateId() { - long current = System.currentTimeMillis(); - return idPrefix + current + counter++; - } - - /** - * Set or generate an Id This method should not be called except when - * populating from the serialization - * - * @generated NOT - */ - public void setId(String newId) { - if (newId == null && id == null) { - id = generateId(); - } else { - id = newId; - } - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public String getReferenceLink() { - return referenceLink; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public void setReferenceLink(String newReferenceLink) { - String oldReferenceLink = referenceLink; - referenceLink = newReferenceLink; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, - PageflowPackage.PAGEFLOW_ELEMENT__REFERENCE_LINK, - oldReferenceLink, referenceLink)); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public Object eGet(EStructuralFeature eFeature, boolean resolve) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case PageflowPackage.PAGEFLOW_ELEMENT__NAME: - return getName(); - case PageflowPackage.PAGEFLOW_ELEMENT__COMMENT: - return getComment(); - case PageflowPackage.PAGEFLOW_ELEMENT__X: - return new Integer(getX()); - case PageflowPackage.PAGEFLOW_ELEMENT__Y: - return new Integer(getY()); - case PageflowPackage.PAGEFLOW_ELEMENT__WIDTH: - return new Integer(getWidth()); - case PageflowPackage.PAGEFLOW_ELEMENT__HEIGHT: - return new Integer(getHeight()); - case PageflowPackage.PAGEFLOW_ELEMENT__ID: - return getId(); - case PageflowPackage.PAGEFLOW_ELEMENT__REFERENCE_LINK: - return getReferenceLink(); - } - return eDynamicGet(eFeature, resolve); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public void eSet(EStructuralFeature eFeature, Object newValue) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case PageflowPackage.PAGEFLOW_ELEMENT__NAME: - setName((String) newValue); - return; - case PageflowPackage.PAGEFLOW_ELEMENT__COMMENT: - setComment((String) newValue); - return; - case PageflowPackage.PAGEFLOW_ELEMENT__X: - setX(((Integer) newValue).intValue()); - return; - case PageflowPackage.PAGEFLOW_ELEMENT__Y: - setY(((Integer) newValue).intValue()); - return; - case PageflowPackage.PAGEFLOW_ELEMENT__WIDTH: - setWidth(((Integer) newValue).intValue()); - return; - case PageflowPackage.PAGEFLOW_ELEMENT__HEIGHT: - setHeight(((Integer) newValue).intValue()); - return; - case PageflowPackage.PAGEFLOW_ELEMENT__ID: - setId((String) newValue); - return; - case PageflowPackage.PAGEFLOW_ELEMENT__REFERENCE_LINK: - setReferenceLink((String) newValue); - return; - } - eDynamicSet(eFeature, newValue); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public void eUnset(EStructuralFeature eFeature) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case PageflowPackage.PAGEFLOW_ELEMENT__NAME: - setName(NAME_EDEFAULT); - return; - case PageflowPackage.PAGEFLOW_ELEMENT__COMMENT: - setComment(COMMENT_EDEFAULT); - return; - case PageflowPackage.PAGEFLOW_ELEMENT__X: - setX(X_EDEFAULT); - return; - case PageflowPackage.PAGEFLOW_ELEMENT__Y: - setY(Y_EDEFAULT); - return; - case PageflowPackage.PAGEFLOW_ELEMENT__WIDTH: - setWidth(WIDTH_EDEFAULT); - return; - case PageflowPackage.PAGEFLOW_ELEMENT__HEIGHT: - setHeight(HEIGHT_EDEFAULT); - return; - case PageflowPackage.PAGEFLOW_ELEMENT__ID: - setId(ID_EDEFAULT); - return; - case PageflowPackage.PAGEFLOW_ELEMENT__REFERENCE_LINK: - setReferenceLink(REFERENCE_LINK_EDEFAULT); - return; - } - eDynamicUnset(eFeature); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public boolean eIsSet(EStructuralFeature eFeature) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case PageflowPackage.PAGEFLOW_ELEMENT__NAME: - return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT - .equals(name); - case PageflowPackage.PAGEFLOW_ELEMENT__COMMENT: - return COMMENT_EDEFAULT == null ? comment != null - : !COMMENT_EDEFAULT.equals(comment); - case PageflowPackage.PAGEFLOW_ELEMENT__X: - return x != X_EDEFAULT; - case PageflowPackage.PAGEFLOW_ELEMENT__Y: - return y != Y_EDEFAULT; - case PageflowPackage.PAGEFLOW_ELEMENT__WIDTH: - return width != WIDTH_EDEFAULT; - case PageflowPackage.PAGEFLOW_ELEMENT__HEIGHT: - return height != HEIGHT_EDEFAULT; - case PageflowPackage.PAGEFLOW_ELEMENT__ID: - return ID_EDEFAULT == null ? getId() != null : !ID_EDEFAULT - .equals(getId()); - case PageflowPackage.PAGEFLOW_ELEMENT__REFERENCE_LINK: - return REFERENCE_LINK_EDEFAULT == null ? referenceLink != null - : !REFERENCE_LINK_EDEFAULT.equals(referenceLink); - } - return eDynamicIsSet(eFeature); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public String toString() { - if (eIsProxy()) - return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (name: "); - result.append(name); - result.append(", comment: "); - result.append(comment); - result.append(", x: "); - result.append(x); - result.append(", y: "); - result.append(y); - result.append(", width: "); - result.append(width); - result.append(", height: "); - result.append(height); - result.append(", referenceLink: "); - result.append(referenceLink); - result.append(')'); - return result.toString(); - } - - /** - * The synchronizer will use this to notify adapters for the faces-config's - * modification. - * - * @generated NOT - */ - public void notifyModelChanged(Notification notification) { - if (eNotificationRequired()) - eNotify(notification); - } - - /** - * @generated NOT - */ - - public ReferenceElement getFCElements() { - return null; - } - - /** - * @generated NOT - */ - public void update() { - getFCElements().update(); - if (!TransformUtil.isValidPageflowElement(this)) { - eAdapters().clear(); - } - } - - /** - * @generated NOT - */ - public void dispose() { - getFCElements().dispose(); - eAdapters.clear(); - } - -} -// PageflowElementImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowFactoryImpl.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowFactoryImpl.java deleted file mode 100644 index 5dcc2ee76..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowFactoryImpl.java +++ /dev/null @@ -1,123 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.impl.EFactoryImpl; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowFactory; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage; - -/** - * <!-- begin-user-doc --> An implementation of the model <b>Factory</b>. <!-- - * end-user-doc --> - * - * @generated - */ -public class PageflowFactoryImpl extends EFactoryImpl implements - PageflowFactory { - /** - * Creates and instance of the factory. <!-- begin-user-doc --> <!-- - * end-user-doc --> - * - * @generated - */ - public PageflowFactoryImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EObject create(EClass eClass) { - switch (eClass.getClassifierID()) { - case PageflowPackage.PAGEFLOW: - return createPageflow(); - case PageflowPackage.PF_LINK: - return createPFLink(); - case PageflowPackage.PF_PAGE: - return createPFPage(); - case PageflowPackage.PF_LINK_BENDPOINT: - return createPFLinkBendpoint(); - default: - throw new IllegalArgumentException("The class '" + eClass.getName() - + "' is not a valid classifier"); - } - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public Pageflow createPageflow() { - PageflowImpl pageflow = new PageflowImpl(); - return pageflow; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public PageflowLink createPFLink() { - PageflowLinkImpl pfLink = new PageflowLinkImpl(); - return pfLink; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public PageflowPage createPFPage() { - PageflowPageImpl pfPage = new PageflowPageImpl(); - return pfPage; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public PageflowLinkBendpoint createPFLinkBendpoint() { - PageflowLinkBendpointImpl pfLinkBendpoint = new PageflowLinkBendpointImpl(); - return pfLinkBendpoint; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public PageflowPackage getPageflowPackage() { - return (PageflowPackage) getEPackage(); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @deprecated - * @generated - */ - public static PageflowPackage getPackage() { - return PageflowPackage.eINSTANCE; - } - -} -// PageflowFactoryImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowImpl.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowImpl.java deleted file mode 100644 index 381e1d279..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowImpl.java +++ /dev/null @@ -1,472 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.NotificationChain; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.common.util.TreeIterator; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; -import org.eclipse.emf.ecore.util.InternalEList; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.util.PageflowValidation; - -/** - * <!-- begin-user-doc --> An implementation of the model object '<em><b>Pageflow</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * <ul> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowImpl#getNodes <em>Nodes</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowImpl#getLinks <em>Links</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowImpl#getConfigfile <em>Configfile</em>}</li> - * </ul> - * </p> - * - * @generated - */ -public class PageflowImpl extends PageflowElementImpl implements Pageflow { - - /** - * The cached value of the '{@link #getNodes() <em>Nodes</em>}' - * containment reference list. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see #getNodes() - * @generated - * @ordered - */ - protected EList nodes = null; - - /** - * The cached value of the '{@link #getLinks() <em>Links</em>}' - * containment reference list. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see #getLinks() - * @generated - * @ordered - */ - protected EList links = null; - - /** - * The default value of the '{@link #getConfigfile() <em>Configfile</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see #getConfigfile() - * @generated - * @ordered - */ - protected static final String CONFIGFILE_EDEFAULT = null; - - /** - * The cached value of the '{@link #getConfigfile() <em>Configfile</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see #getConfigfile() - * @generated - * @ordered - */ - protected String configfile = CONFIGFILE_EDEFAULT; - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - protected PageflowImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - protected EClass eStaticClass() { - return PageflowPackage.eINSTANCE.getPageflow(); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EList getNodes() { - if (nodes == null) { - nodes = new EObjectContainmentWithInverseEList(PageflowNode.class, - this, PageflowPackage.PAGEFLOW__NODES, - PageflowPackage.PAGEFLOW_NODE__PAGEFLOW); - } - return nodes; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EList getLinks() { - if (links == null) { - links = new EObjectContainmentWithInverseEList(PageflowLink.class, - this, PageflowPackage.PAGEFLOW__LINKS, - PageflowPackage.PF_LINK__PAGEFLOW); - } - return links; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public String getConfigfile() { - return configfile; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public void setConfigfile(String newConfigfile) { - String oldConfigfile = configfile; - configfile = newConfigfile; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, - PageflowPackage.PAGEFLOW__CONFIGFILE, oldConfigfile, - configfile)); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public NotificationChain eInverseAdd(InternalEObject otherEnd, - int featureID, Class baseClass, NotificationChain msgs) { - if (featureID >= 0) { - switch (eDerivedStructuralFeatureID(featureID, baseClass)) { - case PageflowPackage.PAGEFLOW__NODES: - return ((InternalEList) getNodes()).basicAdd(otherEnd, msgs); - case PageflowPackage.PAGEFLOW__LINKS: - return ((InternalEList) getLinks()).basicAdd(otherEnd, msgs); - default: - return eDynamicInverseAdd(otherEnd, featureID, baseClass, msgs); - } - } - if (eContainer != null) - msgs = eBasicRemoveFromContainer(msgs); - return eBasicSetContainer(otherEnd, featureID, msgs); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public NotificationChain eInverseRemove(InternalEObject otherEnd, - int featureID, Class baseClass, NotificationChain msgs) { - if (featureID >= 0) { - switch (eDerivedStructuralFeatureID(featureID, baseClass)) { - case PageflowPackage.PAGEFLOW__NODES: - return ((InternalEList) getNodes()).basicRemove(otherEnd, msgs); - case PageflowPackage.PAGEFLOW__LINKS: - return ((InternalEList) getLinks()).basicRemove(otherEnd, msgs); - default: - return eDynamicInverseRemove(otherEnd, featureID, baseClass, - msgs); - } - } - return eBasicSetContainer(null, featureID, msgs); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public Object eGet(EStructuralFeature eFeature, boolean resolve) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case PageflowPackage.PAGEFLOW__NAME: - return getName(); - case PageflowPackage.PAGEFLOW__COMMENT: - return getComment(); - case PageflowPackage.PAGEFLOW__X: - return new Integer(getX()); - case PageflowPackage.PAGEFLOW__Y: - return new Integer(getY()); - case PageflowPackage.PAGEFLOW__WIDTH: - return new Integer(getWidth()); - case PageflowPackage.PAGEFLOW__HEIGHT: - return new Integer(getHeight()); - case PageflowPackage.PAGEFLOW__ID: - return getId(); - case PageflowPackage.PAGEFLOW__NODES: - return getNodes(); - case PageflowPackage.PAGEFLOW__LINKS: - return getLinks(); - case PageflowPackage.PAGEFLOW__CONFIGFILE: - return getConfigfile(); - } - return super.eGet(eFeature, resolve); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public void eSet(EStructuralFeature eFeature, Object newValue) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case PageflowPackage.PAGEFLOW__NAME: - setName((String) newValue); - return; - case PageflowPackage.PAGEFLOW__COMMENT: - setComment((String) newValue); - return; - case PageflowPackage.PAGEFLOW__X: - setX(((Integer) newValue).intValue()); - return; - case PageflowPackage.PAGEFLOW__Y: - setY(((Integer) newValue).intValue()); - return; - case PageflowPackage.PAGEFLOW__WIDTH: - setWidth(((Integer) newValue).intValue()); - return; - case PageflowPackage.PAGEFLOW__HEIGHT: - setHeight(((Integer) newValue).intValue()); - return; - case PageflowPackage.PAGEFLOW__ID: - setId((String) newValue); - return; - case PageflowPackage.PAGEFLOW__NODES: - getNodes().clear(); - getNodes().addAll((Collection) newValue); - return; - case PageflowPackage.PAGEFLOW__LINKS: - getLinks().clear(); - getLinks().addAll((Collection) newValue); - return; - case PageflowPackage.PAGEFLOW__CONFIGFILE: - setConfigfile((String) newValue); - return; - } - super.eSet(eFeature, newValue); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public void eUnset(EStructuralFeature eFeature) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case PageflowPackage.PAGEFLOW__NAME: - setName(NAME_EDEFAULT); - return; - case PageflowPackage.PAGEFLOW__COMMENT: - setComment(COMMENT_EDEFAULT); - return; - case PageflowPackage.PAGEFLOW__X: - setX(X_EDEFAULT); - return; - case PageflowPackage.PAGEFLOW__Y: - setY(Y_EDEFAULT); - return; - case PageflowPackage.PAGEFLOW__WIDTH: - setWidth(WIDTH_EDEFAULT); - return; - case PageflowPackage.PAGEFLOW__HEIGHT: - setHeight(HEIGHT_EDEFAULT); - return; - case PageflowPackage.PAGEFLOW__ID: - setId(ID_EDEFAULT); - return; - case PageflowPackage.PAGEFLOW__NODES: - getNodes().clear(); - return; - case PageflowPackage.PAGEFLOW__LINKS: - getLinks().clear(); - return; - case PageflowPackage.PAGEFLOW__CONFIGFILE: - setConfigfile(CONFIGFILE_EDEFAULT); - return; - } - super.eUnset(eFeature); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public boolean eIsSet(EStructuralFeature eFeature) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case PageflowPackage.PAGEFLOW__NAME: - return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT - .equals(name); - case PageflowPackage.PAGEFLOW__COMMENT: - return COMMENT_EDEFAULT == null ? comment != null - : !COMMENT_EDEFAULT.equals(comment); - case PageflowPackage.PAGEFLOW__X: - return x != X_EDEFAULT; - case PageflowPackage.PAGEFLOW__Y: - return y != Y_EDEFAULT; - case PageflowPackage.PAGEFLOW__WIDTH: - return width != WIDTH_EDEFAULT; - case PageflowPackage.PAGEFLOW__HEIGHT: - return height != HEIGHT_EDEFAULT; - case PageflowPackage.PAGEFLOW__ID: - return ID_EDEFAULT == null ? getId() != null : !ID_EDEFAULT - .equals(getId()); - case PageflowPackage.PAGEFLOW__NODES: - return nodes != null && !nodes.isEmpty(); - case PageflowPackage.PAGEFLOW__LINKS: - return links != null && !links.isEmpty(); - case PageflowPackage.PAGEFLOW__CONFIGFILE: - return CONFIGFILE_EDEFAULT == null ? configfile != null - : !CONFIGFILE_EDEFAULT.equals(configfile); - } - return super.eIsSet(eFeature); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public String toString() { - if (eIsProxy()) - return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (configfile: "); - result.append(configfile); - result.append(')'); - return result.toString(); - } - - /** - * set the valid link's source and target node. - * - * @generated NOT - */ - public void connect(PageflowNode source, PageflowNode target, - PageflowLink link) { - if (link != null) { - if (PageflowValidation.getInstance().isValidLinkForCreation(source, - target)) { - this.getLinks().add(link); - link.setSource(source); - link.setTarget(target); - } - } - } - - /** node prefixs map */ - private HashMap mapNodePrefix = null; - - /** - * get the prefix's map, and if the map is not existed, create it. - * - * @return - map for prefix - * - * @generated NOT - */ - private HashMap getNodePrefixMap() { - if (mapNodePrefix == null) { - mapNodePrefix = new HashMap(); - mapNodePrefix.put(PageflowPageImpl.class, new String("Page")); - } - return mapNodePrefix; - } - - /** - * get the default node name according current nodetype - * - * @param nodeType - - * node type, such as PFBeginImpl, PFPageImpl, etc. - * @return - the default node name. - * - * @generated NOT - */ - public String getDefaultNodeName(Class nodeType) { - HashMap mapNodePrefix_ = getNodePrefixMap(); - - String strNodePrefix = (String) mapNodePrefix_.get(nodeType); - - String strNodeName = null; - boolean bFound = true; - int numNode = 1; - while (bFound) { - strNodeName = strNodePrefix + numNode; - boolean bExisted = false; - for (Iterator iter = getNodes().iterator(); iter.hasNext();) { - PageflowNode node = (PageflowNode) iter.next(); - if (strNodeName.equalsIgnoreCase(node.getName())) { - bExisted = true; - break; - } - } - if (!bExisted) { - bFound = false; - } - numNode++; - } - - return strNodeName; - - } - - /** - * When faces-config has been changed, the pageflow model will be notified - * to enable refresher do some update in pageflow. - * - * @generated NOT - */ - public void notifyModelChanged(Notification notification) { - TreeIterator children = eAllContents(); - while (children.hasNext()) { - Object next = children.next(); - if (next instanceof PageflowElement) { - ((PageflowElement) next).update(); - } - } - super.notifyModelChanged(notification); - } - - /** - * @generated NOT - */ - public void dispose() { - TreeIterator children = eAllContents(); - while (children.hasNext()) { - Object next = children.next(); - if (next instanceof PageflowElement) { - ((PageflowElement) next).dispose(); - } - } - eAdapters.clear(); - } -} -// PageflowImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowLinkBendpointImpl.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowLinkBendpointImpl.java deleted file mode 100644 index 755c51401..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowLinkBendpointImpl.java +++ /dev/null @@ -1,550 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl; - -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.NotificationChain; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.impl.EObjectImpl; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage; - -/** - * <!-- begin-user-doc --> An implementation of the model object '<em><b>PF Link Bendpoint</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * <ul> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowLinkBendpointImpl#getD1Width <em>D1 Width</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowLinkBendpointImpl#getD1Height <em>D1 Height</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowLinkBendpointImpl#getD2Width <em>D2 Width</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowLinkBendpointImpl#getD2Height <em>D2 Height</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowLinkBendpointImpl#getWeight <em>Weight</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowLinkBendpointImpl#getLink <em>Link</em>}</li> - * </ul> - * </p> - * - * @generated - */ -public class PageflowLinkBendpointImpl extends EObjectImpl implements PageflowLinkBendpoint { - /** - * The default value of the '{@link #getD1Width() <em>D1 Width</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see #getD1Width() - * @generated - * @ordered - */ - protected static final int D1_WIDTH_EDEFAULT = 0; - - /** - * The cached value of the '{@link #getD1Width() <em>D1 Width</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see #getD1Width() - * @generated - * @ordered - */ - protected int d1Width = D1_WIDTH_EDEFAULT; - - /** - * The default value of the '{@link #getD1Height() <em>D1 Height</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see #getD1Height() - * @generated - * @ordered - */ - protected static final int D1_HEIGHT_EDEFAULT = 0; - - /** - * The cached value of the '{@link #getD1Height() <em>D1 Height</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see #getD1Height() - * @generated - * @ordered - */ - protected int d1Height = D1_HEIGHT_EDEFAULT; - - /** - * The default value of the '{@link #getD2Width() <em>D2 Width</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see #getD2Width() - * @generated - * @ordered - */ - protected static final int D2_WIDTH_EDEFAULT = 0; - - /** - * The cached value of the '{@link #getD2Width() <em>D2 Width</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see #getD2Width() - * @generated - * @ordered - */ - protected int d2Width = D2_WIDTH_EDEFAULT; - - /** - * The default value of the '{@link #getD2Height() <em>D2 Height</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see #getD2Height() - * @generated - * @ordered - */ - protected static final int D2_HEIGHT_EDEFAULT = 0; - - /** - * The cached value of the '{@link #getD2Height() <em>D2 Height</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see #getD2Height() - * @generated - * @ordered - */ - protected int d2Height = D2_HEIGHT_EDEFAULT; - - /** - * The default value of the '{@link #getWeight() <em>Weight</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see #getWeight() - * @generated - * @ordered - */ - protected static final float WEIGHT_EDEFAULT = 0.5F; - - /** - * The cached value of the '{@link #getWeight() <em>Weight</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see #getWeight() - * @generated - * @ordered - */ - protected float weight = WEIGHT_EDEFAULT; - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated NOT - */ - private Dimension dimStart, dimEnd; - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - protected PageflowLinkBendpointImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - protected EClass eStaticClass() { - return PageflowPackage.eINSTANCE.getPFLinkBendpoint(); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public int getD1Width() { - return d1Width; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public void setD1Width(int newD1Width) { - int oldD1Width = d1Width; - d1Width = newD1Width; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, - PageflowPackage.PF_LINK_BENDPOINT__D1_WIDTH, oldD1Width, - d1Width)); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public int getD1Height() { - return d1Height; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public void setD1Height(int newD1Height) { - int oldD1Height = d1Height; - d1Height = newD1Height; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, - PageflowPackage.PF_LINK_BENDPOINT__D1_HEIGHT, oldD1Height, - d1Height)); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public int getD2Width() { - return d2Width; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public void setD2Width(int newD2Width) { - int oldD2Width = d2Width; - d2Width = newD2Width; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, - PageflowPackage.PF_LINK_BENDPOINT__D2_WIDTH, oldD2Width, - d2Width)); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public int getD2Height() { - return d2Height; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public void setD2Height(int newD2Height) { - int oldD2Height = d2Height; - d2Height = newD2Height; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, - PageflowPackage.PF_LINK_BENDPOINT__D2_HEIGHT, oldD2Height, - d2Height)); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public float getWeight() { - return weight; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public void setWeight(float newWeight) { - float oldWeight = weight; - weight = newWeight; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, - PageflowPackage.PF_LINK_BENDPOINT__WEIGHT, oldWeight, - weight)); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public PageflowLink getLink() { - if (eContainerFeatureID != PageflowPackage.PF_LINK_BENDPOINT__LINK) - return null; - return (PageflowLink) eContainer; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public void setLink(PageflowLink newLink) { - if (newLink != eContainer - || (eContainerFeatureID != PageflowPackage.PF_LINK_BENDPOINT__LINK && newLink != null)) { - if (EcoreUtil.isAncestor(this, newLink)) - throw new IllegalArgumentException( - "Recursive containment not allowed for " + toString()); - NotificationChain msgs = null; - if (eContainer != null) - msgs = eBasicRemoveFromContainer(msgs); - if (newLink != null) - msgs = ((InternalEObject) newLink).eInverseAdd(this, - PageflowPackage.PF_LINK__BEND_POINTS, PageflowLink.class, - msgs); - msgs = eBasicSetContainer((InternalEObject) newLink, - PageflowPackage.PF_LINK_BENDPOINT__LINK, msgs); - if (msgs != null) - msgs.dispatch(); - } else if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, - PageflowPackage.PF_LINK_BENDPOINT__LINK, newLink, newLink)); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public NotificationChain eInverseAdd(InternalEObject otherEnd, - int featureID, Class baseClass, NotificationChain msgs) { - if (featureID >= 0) { - switch (eDerivedStructuralFeatureID(featureID, baseClass)) { - case PageflowPackage.PF_LINK_BENDPOINT__LINK: - if (eContainer != null) - msgs = eBasicRemoveFromContainer(msgs); - return eBasicSetContainer(otherEnd, - PageflowPackage.PF_LINK_BENDPOINT__LINK, msgs); - default: - return eDynamicInverseAdd(otherEnd, featureID, baseClass, msgs); - } - } - if (eContainer != null) - msgs = eBasicRemoveFromContainer(msgs); - return eBasicSetContainer(otherEnd, featureID, msgs); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public NotificationChain eInverseRemove(InternalEObject otherEnd, - int featureID, Class baseClass, NotificationChain msgs) { - if (featureID >= 0) { - switch (eDerivedStructuralFeatureID(featureID, baseClass)) { - case PageflowPackage.PF_LINK_BENDPOINT__LINK: - return eBasicSetContainer(null, - PageflowPackage.PF_LINK_BENDPOINT__LINK, msgs); - default: - return eDynamicInverseRemove(otherEnd, featureID, baseClass, - msgs); - } - } - return eBasicSetContainer(null, featureID, msgs); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public NotificationChain eBasicRemoveFromContainer(NotificationChain msgs) { - if (eContainerFeatureID >= 0) { - switch (eContainerFeatureID) { - case PageflowPackage.PF_LINK_BENDPOINT__LINK: - return eContainer.eInverseRemove(this, - PageflowPackage.PF_LINK__BEND_POINTS, PageflowLink.class, - msgs); - default: - return eDynamicBasicRemoveFromContainer(msgs); - } - } - return eContainer.eInverseRemove(this, - EOPPOSITE_FEATURE_BASE - eContainerFeatureID, null, msgs); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public Object eGet(EStructuralFeature eFeature, boolean resolve) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case PageflowPackage.PF_LINK_BENDPOINT__D1_WIDTH: - return new Integer(getD1Width()); - case PageflowPackage.PF_LINK_BENDPOINT__D1_HEIGHT: - return new Integer(getD1Height()); - case PageflowPackage.PF_LINK_BENDPOINT__D2_WIDTH: - return new Integer(getD2Width()); - case PageflowPackage.PF_LINK_BENDPOINT__D2_HEIGHT: - return new Integer(getD2Height()); - case PageflowPackage.PF_LINK_BENDPOINT__WEIGHT: - return new Float(getWeight()); - case PageflowPackage.PF_LINK_BENDPOINT__LINK: - return getLink(); - } - return eDynamicGet(eFeature, resolve); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public void eSet(EStructuralFeature eFeature, Object newValue) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case PageflowPackage.PF_LINK_BENDPOINT__D1_WIDTH: - setD1Width(((Integer) newValue).intValue()); - return; - case PageflowPackage.PF_LINK_BENDPOINT__D1_HEIGHT: - setD1Height(((Integer) newValue).intValue()); - return; - case PageflowPackage.PF_LINK_BENDPOINT__D2_WIDTH: - setD2Width(((Integer) newValue).intValue()); - return; - case PageflowPackage.PF_LINK_BENDPOINT__D2_HEIGHT: - setD2Height(((Integer) newValue).intValue()); - return; - case PageflowPackage.PF_LINK_BENDPOINT__WEIGHT: - setWeight(((Float) newValue).floatValue()); - return; - case PageflowPackage.PF_LINK_BENDPOINT__LINK: - setLink((PageflowLink) newValue); - return; - } - eDynamicSet(eFeature, newValue); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public void eUnset(EStructuralFeature eFeature) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case PageflowPackage.PF_LINK_BENDPOINT__D1_WIDTH: - setD1Width(D1_WIDTH_EDEFAULT); - return; - case PageflowPackage.PF_LINK_BENDPOINT__D1_HEIGHT: - setD1Height(D1_HEIGHT_EDEFAULT); - return; - case PageflowPackage.PF_LINK_BENDPOINT__D2_WIDTH: - setD2Width(D2_WIDTH_EDEFAULT); - return; - case PageflowPackage.PF_LINK_BENDPOINT__D2_HEIGHT: - setD2Height(D2_HEIGHT_EDEFAULT); - return; - case PageflowPackage.PF_LINK_BENDPOINT__WEIGHT: - setWeight(WEIGHT_EDEFAULT); - return; - case PageflowPackage.PF_LINK_BENDPOINT__LINK: - setLink((PageflowLink) null); - return; - } - eDynamicUnset(eFeature); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public boolean eIsSet(EStructuralFeature eFeature) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case PageflowPackage.PF_LINK_BENDPOINT__D1_WIDTH: - return d1Width != D1_WIDTH_EDEFAULT; - case PageflowPackage.PF_LINK_BENDPOINT__D1_HEIGHT: - return d1Height != D1_HEIGHT_EDEFAULT; - case PageflowPackage.PF_LINK_BENDPOINT__D2_WIDTH: - return d2Width != D2_WIDTH_EDEFAULT; - case PageflowPackage.PF_LINK_BENDPOINT__D2_HEIGHT: - return d2Height != D2_HEIGHT_EDEFAULT; - case PageflowPackage.PF_LINK_BENDPOINT__WEIGHT: - return weight != WEIGHT_EDEFAULT; - case PageflowPackage.PF_LINK_BENDPOINT__LINK: - return getLink() != null; - } - return eDynamicIsSet(eFeature); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public String toString() { - if (eIsProxy()) - return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (d1Width: "); - result.append(d1Width); - result.append(", d1Height: "); - result.append(d1Height); - result.append(", d2Width: "); - result.append(d2Width); - result.append(", d2Height: "); - result.append(d2Height); - result.append(", weight: "); - result.append(weight); - result.append(')'); - return result.toString(); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated NOT - */ - public Dimension getFirstRelativeDimension() { - dimStart = new Dimension(getD1Width(), getD1Height()); - return dimStart; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated NOT - */ - public Dimension getSecondRelativeDimension() { - dimEnd = new Dimension(getD2Width(), getD2Height()); - return dimEnd; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated NOT - */ - public void setRelativeDimensions(Dimension dim1, Dimension dim2) { - dimStart = dim1; - dimEnd = dim2; - setD1Width(dimStart.width); - setD1Height(dimStart.height); - - setD2Width(dimEnd.width); - setD2Height(dimEnd.height); - } - -} -// PFLinkBendpointImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowLinkImpl.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowLinkImpl.java deleted file mode 100644 index d75ccedd2..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowLinkImpl.java +++ /dev/null @@ -1,878 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl; - -import java.util.Collection; -import java.util.Vector; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.NotificationChain; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.emf.ecore.util.InternalEList; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; - -/** - * <!-- begin-user-doc --> An implementation of the model object '<em><b>PF Link</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * <ul> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowLinkImpl#getPageflow <em>Pageflow</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowLinkImpl#getTarget <em>Target</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowLinkImpl#getSource <em>Source</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowLinkImpl#getOutcome <em>Outcome</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowLinkImpl#isRedirect <em>Redirect</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowLinkImpl#getBendPoints <em>Bend Points</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowLinkImpl#getSmallicon <em>Smallicon</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowLinkImpl#getLargeicon <em>Largeicon</em>}</li> - * </ul> - * </p> - * - * @generated - * - */ -public class PageflowLinkImpl extends PageflowElementImpl implements - PageflowLink { - /** - * The cached value of the '{@link #getTarget() <em>Target</em>}' - * reference. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see #getTarget() - * @generated - * @ordered - */ - protected PageflowNode target = null; - - /** - * The cached value of the '{@link #getSource() <em>Source</em>}' - * reference. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see #getSource() - * @generated - * @ordered - */ - protected PageflowNode source = null; - - /** - * The default value of the '{@link #getOutcome() <em>Outcome</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see #getOutcome() - * @generated - * @ordered - */ - protected static final String OUTCOME_EDEFAULT = null; - - /** - * The default value of the '{@link #isRedirect() <em>Redirect</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see #isRedirect() - * @generated - * @ordered - */ - protected static final boolean REDIRECT_EDEFAULT = false; - - /** - * The cached value of the '{@link #getBendPoints() <em>Bend Points</em>}' - * containment reference list. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see #getBendPoints() - * @generated - * @ordered - */ - protected EList bendPoints = null; - - /** - * The default value of the '{@link #getSmallicon() <em>Smallicon</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see #getSmallicon() - * @generated - * @ordered - */ - protected static final String SMALLICON_EDEFAULT = null; - - /** - * The default value of the '{@link #getLargeicon() <em>Largeicon</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see #getLargeicon() - * @generated - * @ordered - */ - protected static final String LARGEICON_EDEFAULT = null; - - /** - * The default value of the '{@link #getFromaction() <em>Fromaction</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see #getFromaction() - * @generated - * @ordered - */ - protected static final String FROMACTION_EDEFAULT = null; - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - protected PageflowLinkImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - protected EClass eStaticClass() { - return PageflowPackage.eINSTANCE.getPFLink(); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public Pageflow getPageflow() { - if (eContainerFeatureID != PageflowPackage.PF_LINK__PAGEFLOW) - return null; - return (Pageflow) eContainer; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public void setPageflow(Pageflow newPageflow) { - if (newPageflow != eContainer - || (eContainerFeatureID != PageflowPackage.PF_LINK__PAGEFLOW && newPageflow != null)) { - if (EcoreUtil.isAncestor(this, newPageflow)) - throw new IllegalArgumentException( - "Recursive containment not allowed for " + toString()); - NotificationChain msgs = null; - if (eContainer != null) - msgs = eBasicRemoveFromContainer(msgs); - if (newPageflow != null) - msgs = ((InternalEObject) newPageflow).eInverseAdd(this, - PageflowPackage.PAGEFLOW__LINKS, Pageflow.class, msgs); - msgs = eBasicSetContainer((InternalEObject) newPageflow, - PageflowPackage.PF_LINK__PAGEFLOW, msgs); - if (msgs != null) - msgs.dispatch(); - } else if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, - PageflowPackage.PF_LINK__PAGEFLOW, newPageflow, newPageflow)); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public PageflowNode getTarget() { - if (target != null && target.eIsProxy()) { - PageflowNode oldTarget = target; - target = (PageflowNode) eResolveProxy((InternalEObject) target); - if (target != oldTarget) { - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.RESOLVE, - PageflowPackage.PF_LINK__TARGET, oldTarget, target)); - } - } - return target; - } - - public void setSourcePath(String path) { - if (getSource() != null - && path.equals(((PageflowPage) getSource()).getPath())) { - return; - } - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, - PageflowPackage.PF_LINK__SOURCE, getSource(), path)); - } - - public void setTargetPath(String path) { - if (getTarget() != null - && path.equals(((PageflowPage) getTarget()).getPath())) { - return; - } - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, - PageflowPackage.PF_LINK__TARGET, getTarget(), path)); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public PageflowNode basicGetTarget() { - return target; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public NotificationChain basicSetTarget(PageflowNode newTarget, - NotificationChain msgs) { - PageflowNode oldTarget = target; - target = newTarget; - if (eNotificationRequired()) { - ENotificationImpl notification = new ENotificationImpl(this, - Notification.SET, PageflowPackage.PF_LINK__TARGET, - oldTarget, newTarget); - if (msgs == null) - msgs = notification; - else - msgs.add(notification); - } - return msgs; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public void setTarget(PageflowNode newTarget) { - if (newTarget != target) { - NotificationChain msgs = null; - if (target != null) - msgs = ((InternalEObject) target).eInverseRemove(this, - PageflowPackage.PAGEFLOW_NODE__INLINKS, - PageflowNode.class, msgs); - if (newTarget != null) - msgs = ((InternalEObject) newTarget).eInverseAdd(this, - PageflowPackage.PAGEFLOW_NODE__INLINKS, - PageflowNode.class, msgs); - msgs = basicSetTarget(newTarget, msgs); - if (msgs != null) - msgs.dispatch(); - } else if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, - PageflowPackage.PF_LINK__TARGET, newTarget, newTarget)); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public PageflowNode getSource() { - if (source != null && source.eIsProxy()) { - PageflowNode oldSource = source; - source = (PageflowNode) eResolveProxy((InternalEObject) source); - if (source != oldSource) { - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.RESOLVE, - PageflowPackage.PF_LINK__SOURCE, oldSource, source)); - } - } - return source; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public PageflowNode basicGetSource() { - return source; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public NotificationChain basicSetSource(PageflowNode newSource, - NotificationChain msgs) { - // Assert.isTrue(newSource != null); - PageflowNode oldSource = source; - source = newSource; - if (eNotificationRequired()) { - ENotificationImpl notification = new ENotificationImpl(this, - Notification.SET, PageflowPackage.PF_LINK__SOURCE, - oldSource, newSource); - if (msgs == null) - msgs = notification; - else - msgs.add(notification); - } - return msgs; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public void setSource(PageflowNode newSource) { - // Assert.isTrue(newSource != null); - if (newSource != source) { - NotificationChain msgs = null; - if (source != null) - msgs = ((InternalEObject) source).eInverseRemove(this, - PageflowPackage.PAGEFLOW_NODE__OUTLINKS, - PageflowNode.class, msgs); - if (newSource != null) - msgs = ((InternalEObject) newSource).eInverseAdd(this, - PageflowPackage.PAGEFLOW_NODE__OUTLINKS, - PageflowNode.class, msgs); - msgs = basicSetSource(newSource, msgs); - if (msgs != null) - msgs.dispatch(); - } else if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, - PageflowPackage.PF_LINK__SOURCE, newSource, newSource)); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EList getBendPoints() { - if (bendPoints == null) { - bendPoints = new EObjectContainmentWithInverseEList( - PageflowLinkBendpoint.class, this, - PageflowPackage.PF_LINK__BEND_POINTS, - PageflowPackage.PF_LINK_BENDPOINT__LINK); - } - return bendPoints; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public NotificationChain eInverseAdd(InternalEObject otherEnd, - int featureID, Class baseClass, NotificationChain msgs) { - if (featureID >= 0) { - switch (eDerivedStructuralFeatureID(featureID, baseClass)) { - case PageflowPackage.PF_LINK__PAGEFLOW: - if (eContainer != null) - msgs = eBasicRemoveFromContainer(msgs); - return eBasicSetContainer(otherEnd, - PageflowPackage.PF_LINK__PAGEFLOW, msgs); - case PageflowPackage.PF_LINK__TARGET: - if (target != null) - msgs = ((InternalEObject) target).eInverseRemove(this, - PageflowPackage.PAGEFLOW_NODE__INLINKS, - PageflowNode.class, msgs); - return basicSetTarget((PageflowNode) otherEnd, msgs); - case PageflowPackage.PF_LINK__SOURCE: - if (source != null) - msgs = ((InternalEObject) source).eInverseRemove(this, - PageflowPackage.PAGEFLOW_NODE__OUTLINKS, - PageflowNode.class, msgs); - return basicSetSource((PageflowNode) otherEnd, msgs); - case PageflowPackage.PF_LINK__BEND_POINTS: - return ((InternalEList) getBendPoints()).basicAdd(otherEnd, - msgs); - default: - return eDynamicInverseAdd(otherEnd, featureID, baseClass, msgs); - } - } - if (eContainer != null) - msgs = eBasicRemoveFromContainer(msgs); - return eBasicSetContainer(otherEnd, featureID, msgs); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public NotificationChain eInverseRemove(InternalEObject otherEnd, - int featureID, Class baseClass, NotificationChain msgs) { - if (featureID >= 0) { - switch (eDerivedStructuralFeatureID(featureID, baseClass)) { - case PageflowPackage.PF_LINK__PAGEFLOW: - return eBasicSetContainer(null, - PageflowPackage.PF_LINK__PAGEFLOW, msgs); - case PageflowPackage.PF_LINK__TARGET: - return basicSetTarget(null, msgs); - case PageflowPackage.PF_LINK__SOURCE: - return basicSetSource(null, msgs); - case PageflowPackage.PF_LINK__BEND_POINTS: - return ((InternalEList) getBendPoints()).basicRemove(otherEnd, - msgs); - default: - return eDynamicInverseRemove(otherEnd, featureID, baseClass, - msgs); - } - } - return eBasicSetContainer(null, featureID, msgs); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public NotificationChain eBasicRemoveFromContainer(NotificationChain msgs) { - if (eContainerFeatureID >= 0) { - switch (eContainerFeatureID) { - case PageflowPackage.PF_LINK__PAGEFLOW: - return eContainer.eInverseRemove(this, - PageflowPackage.PAGEFLOW__LINKS, Pageflow.class, msgs); - default: - return eDynamicBasicRemoveFromContainer(msgs); - } - } - return eContainer.eInverseRemove(this, - EOPPOSITE_FEATURE_BASE - eContainerFeatureID, null, msgs); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public Object eGet(EStructuralFeature eFeature, boolean resolve) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case PageflowPackage.PF_LINK__NAME: - return getName(); - case PageflowPackage.PF_LINK__COMMENT: - return getComment(); - case PageflowPackage.PF_LINK__X: - return new Integer(getX()); - case PageflowPackage.PF_LINK__Y: - return new Integer(getY()); - case PageflowPackage.PF_LINK__WIDTH: - return new Integer(getWidth()); - case PageflowPackage.PF_LINK__HEIGHT: - return new Integer(getHeight()); - case PageflowPackage.PF_LINK__ID: - return getId(); - case PageflowPackage.PF_LINK__PAGEFLOW: - return getPageflow(); - case PageflowPackage.PF_LINK__TARGET: - if (resolve) - return getTarget(); - return basicGetTarget(); - case PageflowPackage.PF_LINK__SOURCE: - if (resolve) - return getSource(); - return basicGetSource(); - case PageflowPackage.PF_LINK__OUTCOME: - return getOutcome(); - case PageflowPackage.PF_LINK__REDIRECT: - return isRedirect() ? Boolean.TRUE : Boolean.FALSE; - case PageflowPackage.PF_LINK__BEND_POINTS: - return getBendPoints(); - case PageflowPackage.PF_LINK__SMALLICON: - return getSmallicon(); - case PageflowPackage.PF_LINK__LARGEICON: - return getLargeicon(); - case PageflowPackage.PF_LINK__FROMACTION: - return getFromaction(); - } - return super.eGet(eFeature, resolve); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public void eSet(EStructuralFeature eFeature, Object newValue) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case PageflowPackage.PF_LINK__NAME: - setName((String) newValue); - return; - case PageflowPackage.PF_LINK__COMMENT: - setComment((String) newValue); - return; - case PageflowPackage.PF_LINK__X: - setX(((Integer) newValue).intValue()); - return; - case PageflowPackage.PF_LINK__Y: - setY(((Integer) newValue).intValue()); - return; - case PageflowPackage.PF_LINK__WIDTH: - setWidth(((Integer) newValue).intValue()); - return; - case PageflowPackage.PF_LINK__HEIGHT: - setHeight(((Integer) newValue).intValue()); - return; - case PageflowPackage.PF_LINK__ID: - setId((String) newValue); - return; - case PageflowPackage.PF_LINK__PAGEFLOW: - setPageflow((Pageflow) newValue); - return; - case PageflowPackage.PF_LINK__TARGET: - setTarget((PageflowNode) newValue); - return; - case PageflowPackage.PF_LINK__SOURCE: - setSource((PageflowNode) newValue); - return; - case PageflowPackage.PF_LINK__OUTCOME: - setOutcome((String) newValue); - return; - case PageflowPackage.PF_LINK__REDIRECT: - setRedirect(((Boolean) newValue).booleanValue()); - return; - case PageflowPackage.PF_LINK__BEND_POINTS: - getBendPoints().clear(); - getBendPoints().addAll((Collection) newValue); - return; - case PageflowPackage.PF_LINK__SMALLICON: - setSmallicon((String) newValue); - return; - case PageflowPackage.PF_LINK__LARGEICON: - setLargeicon((String) newValue); - return; - case PageflowPackage.PF_LINK__FROMACTION: - setFromaction((String) newValue); - return; - } - super.eSet(eFeature, newValue); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public void eUnset(EStructuralFeature eFeature) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case PageflowPackage.PF_LINK__NAME: - setName(NAME_EDEFAULT); - return; - case PageflowPackage.PF_LINK__COMMENT: - setComment(COMMENT_EDEFAULT); - return; - case PageflowPackage.PF_LINK__X: - setX(X_EDEFAULT); - return; - case PageflowPackage.PF_LINK__Y: - setY(Y_EDEFAULT); - return; - case PageflowPackage.PF_LINK__WIDTH: - setWidth(WIDTH_EDEFAULT); - return; - case PageflowPackage.PF_LINK__HEIGHT: - setHeight(HEIGHT_EDEFAULT); - return; - case PageflowPackage.PF_LINK__ID: - setId(ID_EDEFAULT); - return; - case PageflowPackage.PF_LINK__PAGEFLOW: - setPageflow((Pageflow) null); - return; - case PageflowPackage.PF_LINK__TARGET: - setTarget((PageflowNode) null); - return; - case PageflowPackage.PF_LINK__SOURCE: - setSource((PageflowNode) null); - return; - case PageflowPackage.PF_LINK__OUTCOME: - setOutcome(OUTCOME_EDEFAULT); - return; - case PageflowPackage.PF_LINK__REDIRECT: - setRedirect(REDIRECT_EDEFAULT); - return; - case PageflowPackage.PF_LINK__BEND_POINTS: - getBendPoints().clear(); - return; - case PageflowPackage.PF_LINK__SMALLICON: - setSmallicon(SMALLICON_EDEFAULT); - return; - case PageflowPackage.PF_LINK__LARGEICON: - setLargeicon(LARGEICON_EDEFAULT); - return; - case PageflowPackage.PF_LINK__FROMACTION: - setFromaction(FROMACTION_EDEFAULT); - return; - } - super.eUnset(eFeature); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public boolean eIsSet(EStructuralFeature eFeature) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case PageflowPackage.PF_LINK__NAME: - return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT - .equals(name); - case PageflowPackage.PF_LINK__COMMENT: - return COMMENT_EDEFAULT == null ? comment != null - : !COMMENT_EDEFAULT.equals(comment); - case PageflowPackage.PF_LINK__X: - return x != X_EDEFAULT; - case PageflowPackage.PF_LINK__Y: - return y != Y_EDEFAULT; - case PageflowPackage.PF_LINK__WIDTH: - return width != WIDTH_EDEFAULT; - case PageflowPackage.PF_LINK__HEIGHT: - return height != HEIGHT_EDEFAULT; - case PageflowPackage.PF_LINK__ID: - return ID_EDEFAULT == null ? getId() != null : !ID_EDEFAULT - .equals(getId()); - case PageflowPackage.PF_LINK__PAGEFLOW: - return getPageflow() != null; - case PageflowPackage.PF_LINK__TARGET: - return target != null; - case PageflowPackage.PF_LINK__SOURCE: - return source != null; - case PageflowPackage.PF_LINK__OUTCOME: - return OUTCOME_EDEFAULT == null ? getOutcome() != null - : !OUTCOME_EDEFAULT.equals(getOutcome()); - case PageflowPackage.PF_LINK__REDIRECT: - return isRedirect() != REDIRECT_EDEFAULT; - case PageflowPackage.PF_LINK__BEND_POINTS: - return bendPoints != null && !bendPoints.isEmpty(); - case PageflowPackage.PF_LINK__SMALLICON: - return SMALLICON_EDEFAULT == null ? getSmallicon() != null - : !SMALLICON_EDEFAULT.equals(getSmallicon()); - case PageflowPackage.PF_LINK__LARGEICON: - return LARGEICON_EDEFAULT == null ? getLargeicon() != null - : !LARGEICON_EDEFAULT.equals(getLargeicon()); - case PageflowPackage.PF_LINK__FROMACTION: - return FROMACTION_EDEFAULT == null ? getFromaction() != null - : !FROMACTION_EDEFAULT.equals(getFromaction()); - } - return super.eIsSet(eFeature); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public String toString() { - if (eIsProxy()) - return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (smallicon: "); - result.append(getSmallicon()); - result.append(", largeicon: "); - result.append(getLargeicon()); - result.append(", fromaction: "); - result.append(getFromaction()); - result.append(", outcome: "); - result.append(getOutcome()); - result.append(", redirect: "); - result.append(isRedirect()); - result.append(')'); - return result.toString(); - } - - /** - * <!-- begin-user-doc --> insert a new bendpoint to the link <!-- - * end-user-doc --> - * - * @generated NOT - */ - public void insertBendpoint(int index, PageflowLinkBendpoint point) { - getBendPoints().add(index, point); - - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.ADD, - PageflowPackage.PF_LINK__BEND_POINTS, null, point)); - } - - /** - * <!-- begin-user-doc --> remove the current bendpoint <!-- end-user-doc - * --> - * - * @generated NOT - */ - public void removeBendpoint(int index) { - getBendPoints().remove(index); - } - - /** - * <!-- begin-user-doc --> Set the current bendpoint <!-- end-user-doc --> - * - * @generated NOT - */ - public void setBendpoint(int index, PageflowLinkBendpoint point) { - getBendPoints().set(index, point); - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, - PageflowPackage.PF_LINK__BEND_POINTS, null, point)); - - } - - /** - * <!-- begin-user-doc --> Set a group of bendpoints to reconstruct the link - * <!-- end-user-doc --> - * - * @generated NOT - */ - public void setBendpoints(Vector points) { - bendPoints = (EList) points; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.ADD_MANY, - PageflowPackage.PF_LINK__BEND_POINTS, null, points)); - - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated NOT - */ - public boolean isRedirect() { - Boolean result = (Boolean) getFCElements().get( - PageflowPackage.PF_LINK__REDIRECT); - return result.booleanValue(); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated NOT - */ - public void setRedirect(boolean newRedirect) { - Boolean oldRedirect = new Boolean(isRedirect()); - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, - PageflowPackage.PF_LINK__REDIRECT, oldRedirect, - new Boolean(newRedirect))); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated NOT - */ - public String getOutcome() { - String result = (String) getFCElements().get( - PageflowPackage.PF_LINK__OUTCOME); - - return result; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated NOT - */ - public void setOutcome(String newValue) { - String oldOutcome = getOutcome(); - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, - PageflowPackage.PF_LINK__OUTCOME, oldOutcome, newValue)); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated NOT - */ - public String getSmallicon() { - String result = (String) getFCElements().get( - PageflowPackage.PF_LINK__SMALLICON); - return result; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated NOT - */ - public void setSmallicon(String newValue) { - String oldSmallicon = getSmallicon(); - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, - PageflowPackage.PF_LINK__SMALLICON, oldSmallicon, newValue)); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated NOT - */ - public String getLargeicon() { - String result = (String) getFCElements().get( - PageflowPackage.PF_LINK__LARGEICON); - - return result; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated NOT - */ - public void setLargeicon(String newValue) { - String oldLargeIcon = getLargeicon(); - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, - PageflowPackage.PF_LINK__LARGEICON, oldLargeIcon, newValue)); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated NOT - */ - public String getFromaction() { - String result = (String) getFCElements().get( - PageflowPackage.PF_LINK__FROMACTION); - return result; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated NOT - */ - public void setFromaction(String newFromaction) { - String oldFromActionType = getFromaction(); - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, - PageflowPackage.PF_LINK__FROMACTION, oldFromActionType, - newFromaction)); - } - - /** - * @generated NOT - */ - public ReferenceElement getFCElements() { - - if (refElement == null) { - refElement = new LinkReferenceElement(this); - } - return refElement; - } - -} -// PFLinkImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowNodeImpl.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowNodeImpl.java deleted file mode 100644 index 0e86e8706..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowNodeImpl.java +++ /dev/null @@ -1,388 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl; - -import java.util.Collection; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.NotificationChain; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.emf.ecore.util.InternalEList; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage; - -/** - * <!-- begin-user-doc --> An implementation of the model object '<em><b>Node</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * <ul> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowNodeImpl#getPageflow <em>Pageflow</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowNodeImpl#getOutlinks <em>Outlinks</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowNodeImpl#getInlinks <em>Inlinks</em>}</li> - * </ul> - * </p> - * - * @generated - */ -public abstract class PageflowNodeImpl extends PageflowElementImpl implements - PageflowNode { - /** - * The cached value of the '{@link #getOutlinks() <em>Outlinks</em>}' - * reference list. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see #getOutlinks() - * @generated - * @ordered - */ - protected EList outlinks = null; - - /** - * The cached value of the '{@link #getInlinks() <em>Inlinks</em>}' - * reference list. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see #getInlinks() - * @generated - * @ordered - */ - protected EList inlinks = null; - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - protected PageflowNodeImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - protected EClass eStaticClass() { - return PageflowPackage.eINSTANCE.getPageflowNode(); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public Pageflow getPageflow() { - if (eContainerFeatureID != PageflowPackage.PAGEFLOW_NODE__PAGEFLOW) - return null; - return (Pageflow) eContainer; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public void setPageflow(Pageflow newPageflow) { - if (newPageflow != eContainer - || (eContainerFeatureID != PageflowPackage.PAGEFLOW_NODE__PAGEFLOW && newPageflow != null)) { - if (EcoreUtil.isAncestor(this, newPageflow)) - throw new IllegalArgumentException( - "Recursive containment not allowed for " + toString()); - NotificationChain msgs = null; - if (eContainer != null) - msgs = eBasicRemoveFromContainer(msgs); - if (newPageflow != null) - msgs = ((InternalEObject) newPageflow).eInverseAdd(this, - PageflowPackage.PAGEFLOW__NODES, Pageflow.class, msgs); - msgs = eBasicSetContainer((InternalEObject) newPageflow, - PageflowPackage.PAGEFLOW_NODE__PAGEFLOW, msgs); - if (msgs != null) - msgs.dispatch(); - } else if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, - PageflowPackage.PAGEFLOW_NODE__PAGEFLOW, newPageflow, - newPageflow)); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EList getOutlinks() { - if (outlinks == null) { - outlinks = new EObjectWithInverseResolvingEList(PageflowLink.class, this, - PageflowPackage.PAGEFLOW_NODE__OUTLINKS, - PageflowPackage.PF_LINK__SOURCE); - } - return outlinks; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EList getInlinks() { - if (inlinks == null) { - inlinks = new EObjectWithInverseResolvingEList(PageflowLink.class, this, - PageflowPackage.PAGEFLOW_NODE__INLINKS, - PageflowPackage.PF_LINK__TARGET); - } - return inlinks; - } - - /** - * @generated NOT - */ - public PageflowLink findLinkTo(PageflowNode target) { - // - java.util.Iterator i = this.getOutlinks().iterator(); - while (i.hasNext()) { - PageflowLink link = (PageflowLink) i.next(); - if (link.getTarget() == target) - return link; - } - return null; - - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public NotificationChain eInverseAdd(InternalEObject otherEnd, - int featureID, Class baseClass, NotificationChain msgs) { - if (featureID >= 0) { - switch (eDerivedStructuralFeatureID(featureID, baseClass)) { - case PageflowPackage.PAGEFLOW_NODE__PAGEFLOW: - if (eContainer != null) - msgs = eBasicRemoveFromContainer(msgs); - return eBasicSetContainer(otherEnd, - PageflowPackage.PAGEFLOW_NODE__PAGEFLOW, msgs); - case PageflowPackage.PAGEFLOW_NODE__OUTLINKS: - return ((InternalEList) getOutlinks()).basicAdd(otherEnd, msgs); - case PageflowPackage.PAGEFLOW_NODE__INLINKS: - return ((InternalEList) getInlinks()).basicAdd(otherEnd, msgs); - default: - return eDynamicInverseAdd(otherEnd, featureID, baseClass, msgs); - } - } - if (eContainer != null) - msgs = eBasicRemoveFromContainer(msgs); - return eBasicSetContainer(otherEnd, featureID, msgs); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public NotificationChain eInverseRemove(InternalEObject otherEnd, - int featureID, Class baseClass, NotificationChain msgs) { - if (featureID >= 0) { - switch (eDerivedStructuralFeatureID(featureID, baseClass)) { - case PageflowPackage.PAGEFLOW_NODE__PAGEFLOW: - return eBasicSetContainer(null, - PageflowPackage.PAGEFLOW_NODE__PAGEFLOW, msgs); - case PageflowPackage.PAGEFLOW_NODE__OUTLINKS: - return ((InternalEList) getOutlinks()).basicRemove(otherEnd, - msgs); - case PageflowPackage.PAGEFLOW_NODE__INLINKS: - return ((InternalEList) getInlinks()).basicRemove(otherEnd, - msgs); - default: - return eDynamicInverseRemove(otherEnd, featureID, baseClass, - msgs); - } - } - return eBasicSetContainer(null, featureID, msgs); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public NotificationChain eBasicRemoveFromContainer(NotificationChain msgs) { - if (eContainerFeatureID >= 0) { - switch (eContainerFeatureID) { - case PageflowPackage.PAGEFLOW_NODE__PAGEFLOW: - return eContainer.eInverseRemove(this, - PageflowPackage.PAGEFLOW__NODES, Pageflow.class, msgs); - default: - return eDynamicBasicRemoveFromContainer(msgs); - } - } - return eContainer.eInverseRemove(this, - EOPPOSITE_FEATURE_BASE - eContainerFeatureID, null, msgs); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public Object eGet(EStructuralFeature eFeature, boolean resolve) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case PageflowPackage.PAGEFLOW_NODE__NAME: - return getName(); - case PageflowPackage.PAGEFLOW_NODE__COMMENT: - return getComment(); - case PageflowPackage.PAGEFLOW_NODE__X: - return new Integer(getX()); - case PageflowPackage.PAGEFLOW_NODE__Y: - return new Integer(getY()); - case PageflowPackage.PAGEFLOW_NODE__WIDTH: - return new Integer(getWidth()); - case PageflowPackage.PAGEFLOW_NODE__HEIGHT: - return new Integer(getHeight()); - case PageflowPackage.PAGEFLOW_NODE__ID: - return getId(); - case PageflowPackage.PAGEFLOW_NODE__PAGEFLOW: - return getPageflow(); - case PageflowPackage.PAGEFLOW_NODE__OUTLINKS: - return getOutlinks(); - case PageflowPackage.PAGEFLOW_NODE__INLINKS: - return getInlinks(); - } - return super.eGet(eFeature, resolve); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public void eSet(EStructuralFeature eFeature, Object newValue) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case PageflowPackage.PAGEFLOW_NODE__NAME: - setName((String) newValue); - return; - case PageflowPackage.PAGEFLOW_NODE__COMMENT: - setComment((String) newValue); - return; - case PageflowPackage.PAGEFLOW_NODE__X: - setX(((Integer) newValue).intValue()); - return; - case PageflowPackage.PAGEFLOW_NODE__Y: - setY(((Integer) newValue).intValue()); - return; - case PageflowPackage.PAGEFLOW_NODE__WIDTH: - setWidth(((Integer) newValue).intValue()); - return; - case PageflowPackage.PAGEFLOW_NODE__HEIGHT: - setHeight(((Integer) newValue).intValue()); - return; - case PageflowPackage.PAGEFLOW_NODE__ID: - setId((String) newValue); - return; - case PageflowPackage.PAGEFLOW_NODE__PAGEFLOW: - setPageflow((Pageflow) newValue); - return; - case PageflowPackage.PAGEFLOW_NODE__OUTLINKS: - getOutlinks().clear(); - getOutlinks().addAll((Collection) newValue); - return; - case PageflowPackage.PAGEFLOW_NODE__INLINKS: - getInlinks().clear(); - getInlinks().addAll((Collection) newValue); - return; - } - super.eSet(eFeature, newValue); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public void eUnset(EStructuralFeature eFeature) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case PageflowPackage.PAGEFLOW_NODE__NAME: - setName(NAME_EDEFAULT); - return; - case PageflowPackage.PAGEFLOW_NODE__COMMENT: - setComment(COMMENT_EDEFAULT); - return; - case PageflowPackage.PAGEFLOW_NODE__X: - setX(X_EDEFAULT); - return; - case PageflowPackage.PAGEFLOW_NODE__Y: - setY(Y_EDEFAULT); - return; - case PageflowPackage.PAGEFLOW_NODE__WIDTH: - setWidth(WIDTH_EDEFAULT); - return; - case PageflowPackage.PAGEFLOW_NODE__HEIGHT: - setHeight(HEIGHT_EDEFAULT); - return; - case PageflowPackage.PAGEFLOW_NODE__ID: - setId(ID_EDEFAULT); - return; - case PageflowPackage.PAGEFLOW_NODE__PAGEFLOW: - setPageflow((Pageflow) null); - return; - case PageflowPackage.PAGEFLOW_NODE__OUTLINKS: - getOutlinks().clear(); - return; - case PageflowPackage.PAGEFLOW_NODE__INLINKS: - getInlinks().clear(); - return; - } - super.eUnset(eFeature); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public boolean eIsSet(EStructuralFeature eFeature) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case PageflowPackage.PAGEFLOW_NODE__NAME: - return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT - .equals(name); - case PageflowPackage.PAGEFLOW_NODE__COMMENT: - return COMMENT_EDEFAULT == null ? comment != null - : !COMMENT_EDEFAULT.equals(comment); - case PageflowPackage.PAGEFLOW_NODE__X: - return x != X_EDEFAULT; - case PageflowPackage.PAGEFLOW_NODE__Y: - return y != Y_EDEFAULT; - case PageflowPackage.PAGEFLOW_NODE__WIDTH: - return width != WIDTH_EDEFAULT; - case PageflowPackage.PAGEFLOW_NODE__HEIGHT: - return height != HEIGHT_EDEFAULT; - case PageflowPackage.PAGEFLOW_NODE__ID: - return ID_EDEFAULT == null ? getId() != null : !ID_EDEFAULT - .equals(getId()); - case PageflowPackage.PAGEFLOW_NODE__PAGEFLOW: - return getPageflow() != null; - case PageflowPackage.PAGEFLOW_NODE__OUTLINKS: - return outlinks != null && !outlinks.isEmpty(); - case PageflowPackage.PAGEFLOW_NODE__INLINKS: - return inlinks != null && !inlinks.isEmpty(); - } - return super.eIsSet(eFeature); - } - -} -// PageflowNodeImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowPackageImpl.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowPackageImpl.java deleted file mode 100644 index 90b0866f1..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowPackageImpl.java +++ /dev/null @@ -1,773 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl; - -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EReference; -import org.eclipse.emf.ecore.impl.EPackageImpl; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowFactory; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; - -/** - * <!-- begin-user-doc --> An implementation of the model <b>Package</b>. <!-- - * end-user-doc --> - * - * @generated - */ -public class PageflowPackageImpl extends EPackageImpl implements - PageflowPackage { - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - private EClass pageflowEClass = null; - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - private EClass pageflowNodeEClass = null; - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - private EClass pfLinkEClass = null; - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - private EClass pageflowElementEClass = null; - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - private EClass pfPageEClass = null; - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - private EClass pfLinkBendpointEClass = null; - - /** - * Creates an instance of the model <b>Package</b>, registered with - * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the - * package package URI value. - * <p> - * Note: the correct way to create the package is via the static factory - * method {@link #init init()}, which also performs initialization of the - * package, or returns the registered package, if one already exists. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @see org.eclipse.emf.ecore.EPackage.Registry - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage#eNS_URI - * @see #init() - * @generated - */ - private PageflowPackageImpl() { - super(eNS_URI, PageflowFactory.eINSTANCE); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - private static boolean isInited = false; - - /** - * Creates, registers, and initializes the <b>Package</b> for this model, - * and for any others upon which it depends. Simple dependencies are - * satisfied by calling this method on all dependent packages before doing - * anything else. This method drives initialization for interdependent - * packages directly, in parallel with this package, itself. - * <p> - * Of this package and its interdependencies, all packages which have not - * yet been registered by their URI values are first created and registered. - * The packages are then initialized in two steps: meta-model objects for - * all of the packages are created before any are initialized, since one - * package's meta-model objects may refer to those of another. - * <p> - * Invocation of this method will not affect any packages that have already - * been initialized. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see #eNS_URI - * @see #createPackageContents() - * @see #initializePackageContents() - * @generated - */ - public static PageflowPackage init() { - if (isInited) - return (PageflowPackage) EPackage.Registry.INSTANCE - .get(PageflowPackage.eNS_URI); - - // Obtain or create and register package - PageflowPackageImpl thePageflowPackage = (PageflowPackageImpl) (EPackage.Registry.INSTANCE - .get(eNS_URI) instanceof PageflowPackageImpl ? EPackage.Registry.INSTANCE - .get(eNS_URI) - : new PageflowPackageImpl()); - - isInited = true; - - // Create package meta-data objects - thePageflowPackage.createPackageContents(); - - // Initialize created meta-data - thePageflowPackage.initializePackageContents(); - - return thePageflowPackage; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EClass getPageflow() { - return pageflowEClass; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EReference getPageflow_Nodes() { - return (EReference) pageflowEClass.getEStructuralFeatures().get(0); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EReference getPageflow_Links() { - return (EReference) pageflowEClass.getEStructuralFeatures().get(1); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EAttribute getPageflow_Configfile() { - return (EAttribute) pageflowEClass.getEStructuralFeatures().get(2); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EClass getPageflowNode() { - return pageflowNodeEClass; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EReference getPageflowNode_Pageflow() { - return (EReference) pageflowNodeEClass.getEStructuralFeatures().get(0); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EReference getPageflowNode_Outlinks() { - return (EReference) pageflowNodeEClass.getEStructuralFeatures().get(1); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EReference getPageflowNode_Inlinks() { - return (EReference) pageflowNodeEClass.getEStructuralFeatures().get(2); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EClass getPFLink() { - return pfLinkEClass; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EReference getPFLink_Pageflow() { - return (EReference) pfLinkEClass.getEStructuralFeatures().get(0); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EReference getPFLink_Target() { - return (EReference) pfLinkEClass.getEStructuralFeatures().get(1); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EReference getPFLink_Source() { - return (EReference) pfLinkEClass.getEStructuralFeatures().get(2); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EAttribute getPFLink_Outcome() { - return (EAttribute) pfLinkEClass.getEStructuralFeatures().get(3); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EAttribute getPFLink_Redirect() { - return (EAttribute) pfLinkEClass.getEStructuralFeatures().get(4); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EReference getPFLink_BendPoints() { - return (EReference) pfLinkEClass.getEStructuralFeatures().get(5); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EAttribute getPFLink_Smallicon() { - return (EAttribute) pfLinkEClass.getEStructuralFeatures().get(6); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EAttribute getPFLink_Largeicon() { - return (EAttribute) pfLinkEClass.getEStructuralFeatures().get(7); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EAttribute getPFLink_Fromaction() { - return (EAttribute) pfLinkEClass.getEStructuralFeatures().get(8); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EAttribute getPageflowElement_ReferenceLink() { - return (EAttribute) pageflowElementEClass.getEStructuralFeatures().get( - 7); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EClass getPageflowElement() { - return pageflowElementEClass; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EAttribute getPageflowElement_Name() { - return (EAttribute) pageflowElementEClass.getEStructuralFeatures().get( - 0); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EAttribute getPageflowElement_Comment() { - return (EAttribute) pageflowElementEClass.getEStructuralFeatures().get( - 1); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EAttribute getPageflowElement_X() { - return (EAttribute) pageflowElementEClass.getEStructuralFeatures().get( - 2); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EAttribute getPageflowElement_Y() { - return (EAttribute) pageflowElementEClass.getEStructuralFeatures().get( - 3); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EAttribute getPageflowElement_Width() { - return (EAttribute) pageflowElementEClass.getEStructuralFeatures().get( - 4); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EAttribute getPageflowElement_Height() { - return (EAttribute) pageflowElementEClass.getEStructuralFeatures().get( - 5); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EAttribute getPageflowElement_Id() { - return (EAttribute) pageflowElementEClass.getEStructuralFeatures().get( - 6); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EClass getPFPage() { - return pfPageEClass; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EAttribute getPFPage_Path() { - return (EAttribute) pfPageEClass.getEStructuralFeatures().get(0); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EAttribute getPFPage_Smallicon() { - return (EAttribute) pfPageEClass.getEStructuralFeatures().get(1); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EAttribute getPFPage_Largeicon() { - return (EAttribute) pfPageEClass.getEStructuralFeatures().get(2); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EClass getPFLinkBendpoint() { - return pfLinkBendpointEClass; - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EAttribute getPFLinkBendpoint_D1Width() { - return (EAttribute) pfLinkBendpointEClass.getEStructuralFeatures().get( - 0); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EAttribute getPFLinkBendpoint_D1Height() { - return (EAttribute) pfLinkBendpointEClass.getEStructuralFeatures().get( - 1); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EAttribute getPFLinkBendpoint_D2Width() { - return (EAttribute) pfLinkBendpointEClass.getEStructuralFeatures().get( - 2); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EAttribute getPFLinkBendpoint_D2Height() { - return (EAttribute) pfLinkBendpointEClass.getEStructuralFeatures().get( - 3); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EAttribute getPFLinkBendpoint_Weight() { - return (EAttribute) pfLinkBendpointEClass.getEStructuralFeatures().get( - 4); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public EReference getPFLinkBendpoint_Link() { - return (EReference) pfLinkBendpointEClass.getEStructuralFeatures().get( - 5); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public PageflowFactory getPageflowFactory() { - return (PageflowFactory) getEFactoryInstance(); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - private boolean isCreated = false; - - /** - * Creates the meta-model objects for the package. This method is guarded to - * have no affect on any invocation but its first. <!-- begin-user-doc --> - * <!-- end-user-doc --> - * - * @generated - */ - public void createPackageContents() { - if (isCreated) - return; - isCreated = true; - - // Create classes and their features - pageflowEClass = createEClass(PAGEFLOW); - createEReference(pageflowEClass, PAGEFLOW__NODES); - createEReference(pageflowEClass, PAGEFLOW__LINKS); - createEAttribute(pageflowEClass, PAGEFLOW__CONFIGFILE); - - pageflowNodeEClass = createEClass(PAGEFLOW_NODE); - createEReference(pageflowNodeEClass, PAGEFLOW_NODE__PAGEFLOW); - createEReference(pageflowNodeEClass, PAGEFLOW_NODE__OUTLINKS); - createEReference(pageflowNodeEClass, PAGEFLOW_NODE__INLINKS); - - pfLinkEClass = createEClass(PF_LINK); - createEReference(pfLinkEClass, PF_LINK__PAGEFLOW); - createEReference(pfLinkEClass, PF_LINK__TARGET); - createEReference(pfLinkEClass, PF_LINK__SOURCE); - createEAttribute(pfLinkEClass, PF_LINK__OUTCOME); - createEAttribute(pfLinkEClass, PF_LINK__REDIRECT); - createEReference(pfLinkEClass, PF_LINK__BEND_POINTS); - createEAttribute(pfLinkEClass, PF_LINK__SMALLICON); - createEAttribute(pfLinkEClass, PF_LINK__LARGEICON); - createEAttribute(pfLinkEClass, PF_LINK__FROMACTION); - - pageflowElementEClass = createEClass(PAGEFLOW_ELEMENT); - createEAttribute(pageflowElementEClass, PAGEFLOW_ELEMENT__NAME); - createEAttribute(pageflowElementEClass, PAGEFLOW_ELEMENT__COMMENT); - createEAttribute(pageflowElementEClass, PAGEFLOW_ELEMENT__X); - createEAttribute(pageflowElementEClass, PAGEFLOW_ELEMENT__Y); - createEAttribute(pageflowElementEClass, PAGEFLOW_ELEMENT__WIDTH); - createEAttribute(pageflowElementEClass, PAGEFLOW_ELEMENT__HEIGHT); - createEAttribute(pageflowElementEClass, PAGEFLOW_ELEMENT__ID); - createEAttribute(pageflowElementEClass, - PAGEFLOW_ELEMENT__REFERENCE_LINK); - - pfPageEClass = createEClass(PF_PAGE); - createEAttribute(pfPageEClass, PF_PAGE__PATH); - createEAttribute(pfPageEClass, PF_PAGE__SMALLICON); - createEAttribute(pfPageEClass, PF_PAGE__LARGEICON); - - pfLinkBendpointEClass = createEClass(PF_LINK_BENDPOINT); - createEAttribute(pfLinkBendpointEClass, PF_LINK_BENDPOINT__D1_WIDTH); - createEAttribute(pfLinkBendpointEClass, PF_LINK_BENDPOINT__D1_HEIGHT); - createEAttribute(pfLinkBendpointEClass, PF_LINK_BENDPOINT__D2_WIDTH); - createEAttribute(pfLinkBendpointEClass, PF_LINK_BENDPOINT__D2_HEIGHT); - createEAttribute(pfLinkBendpointEClass, PF_LINK_BENDPOINT__WEIGHT); - createEReference(pfLinkBendpointEClass, PF_LINK_BENDPOINT__LINK); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - private boolean isInitialized = false; - - /** - * Complete the initialization of the package and its meta-model. This - * method is guarded to have no affect on any invocation but its first. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public void initializePackageContents() { - if (isInitialized) - return; - isInitialized = true; - - // Initialize package - setName(eNAME); - setNsPrefix(eNS_PREFIX); - setNsURI(eNS_URI); - - // Add supertypes to classes - pageflowEClass.getESuperTypes().add(this.getPageflowElement()); - pageflowNodeEClass.getESuperTypes().add(this.getPageflowElement()); - pfLinkEClass.getESuperTypes().add(this.getPageflowElement()); - pfPageEClass.getESuperTypes().add(this.getPageflowNode()); - - // Initialize classes and features; add operations and parameters - initEClass(pageflowEClass, Pageflow.class, "Pageflow", !IS_ABSTRACT, - !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEReference(getPageflow_Nodes(), this.getPageflowNode(), this - .getPageflowNode_Pageflow(), "nodes", null, 0, -1, - Pageflow.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, - IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, - !IS_DERIVED, IS_ORDERED); - initEReference(getPageflow_Links(), this.getPFLink(), this - .getPFLink_Pageflow(), "links", null, 0, -1, Pageflow.class, - !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, - !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, - IS_ORDERED); - initEAttribute(getPageflow_Configfile(), ecorePackage.getEString(), - "configfile", null, 0, 1, Pageflow.class, !IS_TRANSIENT, - !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, - !IS_DERIVED, IS_ORDERED); - - initEClass(pageflowNodeEClass, PageflowNode.class, "PageflowNode", - IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEReference(getPageflowNode_Pageflow(), this.getPageflow(), this - .getPageflow_Nodes(), "pageflow", null, 1, 1, - PageflowNode.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, - !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, - !IS_DERIVED, IS_ORDERED); - initEReference(getPageflowNode_Outlinks(), this.getPFLink(), this - .getPFLink_Source(), "outlinks", null, 0, -1, - PageflowNode.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, - !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, - !IS_DERIVED, IS_ORDERED); - initEReference(getPageflowNode_Inlinks(), this.getPFLink(), this - .getPFLink_Target(), "inlinks", null, 0, -1, - PageflowNode.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, - !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, - !IS_DERIVED, IS_ORDERED); - - initEClass(pfLinkEClass, PageflowLink.class, "PFLink", !IS_ABSTRACT, - !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEReference(getPFLink_Pageflow(), this.getPageflow(), this - .getPageflow_Links(), "pageflow", null, 1, 1, - PageflowLink.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, - !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, - !IS_DERIVED, IS_ORDERED); - initEReference(getPFLink_Target(), this.getPageflowNode(), this - .getPageflowNode_Inlinks(), "target", null, 1, 1, - PageflowLink.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, - !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, - !IS_DERIVED, IS_ORDERED); - initEReference(getPFLink_Source(), this.getPageflowNode(), this - .getPageflowNode_Outlinks(), "source", null, 1, 1, - PageflowLink.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, - !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, - !IS_DERIVED, IS_ORDERED); - initEAttribute(getPFLink_Outcome(), ecorePackage.getEString(), - "outcome", null, 0, 1, PageflowLink.class, !IS_TRANSIENT, - !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, - !IS_DERIVED, IS_ORDERED); - initEAttribute(getPFLink_Redirect(), ecorePackage.getEBoolean(), - "redirect", null, 0, 1, PageflowLink.class, !IS_TRANSIENT, - !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, - !IS_DERIVED, IS_ORDERED); - initEReference(getPFLink_BendPoints(), this.getPFLinkBendpoint(), this - .getPFLinkBendpoint_Link(), "bendPoints", null, 0, -1, - PageflowLink.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, - IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, - !IS_DERIVED, IS_ORDERED); - initEAttribute(getPFLink_Smallicon(), ecorePackage.getEString(), - "smallicon", null, 0, 1, PageflowLink.class, !IS_TRANSIENT, - !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, - !IS_DERIVED, IS_ORDERED); - initEAttribute(getPFLink_Largeicon(), ecorePackage.getEString(), - "largeicon", null, 0, 1, PageflowLink.class, !IS_TRANSIENT, - !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, - !IS_DERIVED, IS_ORDERED); - initEAttribute(getPFLink_Fromaction(), ecorePackage.getEString(), - "fromaction", null, 0, 1, PageflowLink.class, !IS_TRANSIENT, - !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, - !IS_DERIVED, IS_ORDERED); - - initEClass(pageflowElementEClass, PageflowElement.class, - "PageflowElement", IS_ABSTRACT, !IS_INTERFACE, - IS_GENERATED_INSTANCE_CLASS); - initEAttribute(getPageflowElement_Name(), ecorePackage.getEString(), - "name", "unnamed", 0, 1, PageflowElement.class, !IS_TRANSIENT, - !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, - !IS_DERIVED, IS_ORDERED); - initEAttribute(getPageflowElement_Comment(), ecorePackage.getEString(), - "comment", null, 0, 1, PageflowElement.class, !IS_TRANSIENT, - !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, - !IS_DERIVED, IS_ORDERED); - initEAttribute(getPageflowElement_X(), ecorePackage.getEInt(), "x", - "0", 0, 1, PageflowElement.class, !IS_TRANSIENT, !IS_VOLATILE, - IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, - IS_ORDERED); - initEAttribute(getPageflowElement_Y(), ecorePackage.getEInt(), "y", - "0", 0, 1, PageflowElement.class, !IS_TRANSIENT, !IS_VOLATILE, - IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, - IS_ORDERED); - initEAttribute(getPageflowElement_Width(), ecorePackage.getEInt(), - "width", "-1", 0, 1, PageflowElement.class, !IS_TRANSIENT, - !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, - !IS_DERIVED, IS_ORDERED); - initEAttribute(getPageflowElement_Height(), ecorePackage.getEInt(), - "height", "-1", 0, 1, PageflowElement.class, !IS_TRANSIENT, - !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, - !IS_DERIVED, IS_ORDERED); - initEAttribute(getPageflowElement_Id(), ecorePackage.getEString(), - "id", null, 1, 1, PageflowElement.class, !IS_TRANSIENT, - IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, IS_ID, IS_UNIQUE, - !IS_DERIVED, IS_ORDERED); - initEAttribute(getPageflowElement_ReferenceLink(), ecorePackage - .getEString(), "referenceLink", "", 0, 1, - PageflowElement.class, !IS_TRANSIENT, !IS_VOLATILE, - IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, - IS_ORDERED); - - initEClass(pfPageEClass, PageflowPage.class, "PFPage", !IS_ABSTRACT, - !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEAttribute(getPFPage_Path(), ecorePackage.getEString(), "path", - null, 0, 1, PageflowPage.class, !IS_TRANSIENT, !IS_VOLATILE, - IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, - IS_ORDERED); - initEAttribute(getPFPage_Smallicon(), ecorePackage.getEString(), - "smallicon", null, 0, 1, PageflowPage.class, !IS_TRANSIENT, - !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, - !IS_DERIVED, IS_ORDERED); - initEAttribute(getPFPage_Largeicon(), ecorePackage.getEString(), - "largeicon", null, 0, 1, PageflowPage.class, !IS_TRANSIENT, - !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, - !IS_DERIVED, IS_ORDERED); - - initEClass(pfLinkBendpointEClass, PageflowLinkBendpoint.class, - "PFLinkBendpoint", !IS_ABSTRACT, !IS_INTERFACE, - IS_GENERATED_INSTANCE_CLASS); - initEAttribute(getPFLinkBendpoint_D1Width(), ecorePackage.getEInt(), - "d1Width", null, 0, 1, PageflowLinkBendpoint.class, - !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, - !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getPFLinkBendpoint_D1Height(), ecorePackage.getEInt(), - "d1Height", null, 0, 1, PageflowLinkBendpoint.class, - !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, - !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getPFLinkBendpoint_D2Width(), ecorePackage.getEInt(), - "d2Width", null, 0, 1, PageflowLinkBendpoint.class, - !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, - !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getPFLinkBendpoint_D2Height(), ecorePackage.getEInt(), - "d2Height", null, 0, 1, PageflowLinkBendpoint.class, - !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, - !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getPFLinkBendpoint_Weight(), ecorePackage.getEFloat(), - "weight", "0.5", 0, 1, PageflowLinkBendpoint.class, - !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, - !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEReference(getPFLinkBendpoint_Link(), this.getPFLink(), this - .getPFLink_BendPoints(), "link", null, 1, 1, - PageflowLinkBendpoint.class, !IS_TRANSIENT, !IS_VOLATILE, - IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, - !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - - // Create resource - createResource(eNS_URI); - } - -} -// PageflowPackageImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowPageImpl.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowPageImpl.java deleted file mode 100644 index 11d99e1e0..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/PageflowPageImpl.java +++ /dev/null @@ -1,531 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl; - -import java.util.Collection; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.NotificationChain; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.emf.ecore.util.InternalEList; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; - -/** - * <!-- begin-user-doc --> An implementation of the model object '<em><b>PF Page</b></em>'. - * <!-- end-user-doc --> - * <p> - * The following features are implemented: - * <ul> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowPageImpl#getPath <em>Path</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowPageImpl#getSmallicon <em>Smallicon</em>}</li> - * <li>{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowPageImpl#getLargeicon <em>Largeicon</em>}</li> - * </ul> - * </p> - * - * @generated - */ -public class PageflowPageImpl extends PageflowNodeImpl implements PageflowPage { - private String path; - - private String smallIcon; - - private String largeIcon; - - /** - * The default value of the '{@link #getPath() <em>Path</em>}' attribute. - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see #getPath() - * @generated - * @ordered - */ - protected static final String PATH_EDEFAULT = null; - - /** - * The default value of the '{@link #getSmallicon() <em>Smallicon</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see #getSmallicon() - * @generated - * @ordered - */ - protected static final String SMALLICON_EDEFAULT = null; - - /** - * The default value of the '{@link #getLargeicon() <em>Largeicon</em>}' - * attribute. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @see #getLargeicon() - * @generated - * @ordered - */ - protected static final String LARGEICON_EDEFAULT = null; - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - protected PageflowPageImpl() { - super(); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - protected EClass eStaticClass() { - return PageflowPackage.eINSTANCE.getPFPage(); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public String getPath() { - String result = (String) getFCElements().get( - PageflowPackage.PF_PAGE__PATH); - // Try to return reasonable result. - return result == null && getFCElements().isEmpty() ? path - : (result != null ? result : PATH_EDEFAULT); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated NOT - */ - public void setPath(String newValue) { - String oldPath = getPath(); - path = newValue; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, - PageflowPackage.PF_PAGE__PATH, oldPath, newValue)); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated NOT - */ - - public void setComment(String newValue) { - super.setComment(newValue); - String oldComment = getComment(); - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, - PageflowPackage.PAGEFLOW_ELEMENT__COMMENT, oldComment, - newValue)); - - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated NOT - */ - - public String getComment() { - String result = (String) getFCElements().get( - PageflowPackage.PF_PAGE__COMMENT); - return result == null - && (getFCElements().isEmpty() || ((PageReferenceElement) getFCElements()) - .isEndOnly()) ? super.getComment() - : (result != null ? result - : PageflowElementImpl.COMMENT_EDEFAULT); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated NOT - */ - - public String getName() { - String result; - // To see if it is in navigation rule. - result = (String) getFCElements().get(PageflowPackage.PF_PAGE__NAME); - if (result == null) { - if (super.getName() == null || super.getName().trim().length() == 0) { - result = getPath(); - } else { - result = super.getName(); - } - } - return result == null - && (getFCElements().isEmpty() || ((PageReferenceElement) getFCElements()) - .isEndOnly()) ? PageflowElementImpl.NAME_EDEFAULT - : (result == null ? null : result); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated NOT - */ - - public void setName(String newName) { - super.setName(newName); - String oldName = getName(); - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, - PageflowPackage.PF_PAGE__NAME, oldName, newName)); - - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated NOT - */ - public String getSmallicon() { - String result = (String) getFCElements().get( - PageflowPackage.PF_PAGE__SMALLICON); - - return result == null - && (getFCElements().isEmpty() || ((PageReferenceElement) getFCElements()) - .isEndOnly()) ? smallIcon : (result != null ? result - : SMALLICON_EDEFAULT); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated NOT - */ - public void setSmallicon(String newValue) { - String oldSmallicon = getSmallicon(); - smallIcon = newValue; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, - PageflowPackage.PF_PAGE__SMALLICON, oldSmallicon, newValue)); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated NOT - */ - public String getLargeicon() { - String result = (String) getFCElements().get( - PageflowPackage.PF_PAGE__LARGEICON); - - return result == null - && (getFCElements().isEmpty() || ((PageReferenceElement) getFCElements()) - .isEndOnly()) ? largeIcon : (result != null ? result - : LARGEICON_EDEFAULT); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated NOT - */ - public void setLargeicon(String newValue) { - String oldLargeIcon = getLargeicon(); - largeIcon = newValue; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, - PageflowPackage.PF_PAGE__LARGEICON, oldLargeIcon, newValue)); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public NotificationChain eInverseAdd(InternalEObject otherEnd, - int featureID, Class baseClass, NotificationChain msgs) { - if (featureID >= 0) { - switch (eDerivedStructuralFeatureID(featureID, baseClass)) { - case PageflowPackage.PF_PAGE__PAGEFLOW: - if (eContainer != null) - msgs = eBasicRemoveFromContainer(msgs); - return eBasicSetContainer(otherEnd, - PageflowPackage.PF_PAGE__PAGEFLOW, msgs); - case PageflowPackage.PF_PAGE__OUTLINKS: - return ((InternalEList) getOutlinks()).basicAdd(otherEnd, msgs); - case PageflowPackage.PF_PAGE__INLINKS: - return ((InternalEList) getInlinks()).basicAdd(otherEnd, msgs); - default: - return eDynamicInverseAdd(otherEnd, featureID, baseClass, msgs); - } - } - if (eContainer != null) - msgs = eBasicRemoveFromContainer(msgs); - return eBasicSetContainer(otherEnd, featureID, msgs); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public NotificationChain eInverseRemove(InternalEObject otherEnd, - int featureID, Class baseClass, NotificationChain msgs) { - if (featureID >= 0) { - switch (eDerivedStructuralFeatureID(featureID, baseClass)) { - case PageflowPackage.PF_PAGE__PAGEFLOW: - return eBasicSetContainer(null, - PageflowPackage.PF_PAGE__PAGEFLOW, msgs); - case PageflowPackage.PF_PAGE__OUTLINKS: - return ((InternalEList) getOutlinks()).basicRemove(otherEnd, - msgs); - case PageflowPackage.PF_PAGE__INLINKS: - return ((InternalEList) getInlinks()).basicRemove(otherEnd, - msgs); - default: - return eDynamicInverseRemove(otherEnd, featureID, baseClass, - msgs); - } - } - return eBasicSetContainer(null, featureID, msgs); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public NotificationChain eBasicRemoveFromContainer(NotificationChain msgs) { - if (eContainerFeatureID >= 0) { - switch (eContainerFeatureID) { - case PageflowPackage.PF_PAGE__PAGEFLOW: - return eContainer.eInverseRemove(this, - PageflowPackage.PAGEFLOW__NODES, Pageflow.class, msgs); - default: - return eDynamicBasicRemoveFromContainer(msgs); - } - } - return eContainer.eInverseRemove(this, - EOPPOSITE_FEATURE_BASE - eContainerFeatureID, null, msgs); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public Object eGet(EStructuralFeature eFeature, boolean resolve) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case PageflowPackage.PF_PAGE__NAME: - return getName(); - case PageflowPackage.PF_PAGE__COMMENT: - return getComment(); - case PageflowPackage.PF_PAGE__X: - return new Integer(getX()); - case PageflowPackage.PF_PAGE__Y: - return new Integer(getY()); - case PageflowPackage.PF_PAGE__WIDTH: - return new Integer(getWidth()); - case PageflowPackage.PF_PAGE__HEIGHT: - return new Integer(getHeight()); - case PageflowPackage.PF_PAGE__ID: - return getId(); - case PageflowPackage.PF_PAGE__PAGEFLOW: - return getPageflow(); - case PageflowPackage.PF_PAGE__OUTLINKS: - return getOutlinks(); - case PageflowPackage.PF_PAGE__INLINKS: - return getInlinks(); - case PageflowPackage.PF_PAGE__PATH: - return getPath(); - case PageflowPackage.PF_PAGE__SMALLICON: - return getSmallicon(); - case PageflowPackage.PF_PAGE__LARGEICON: - return getLargeicon(); - } - return super.eGet(eFeature, resolve); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public void eSet(EStructuralFeature eFeature, Object newValue) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case PageflowPackage.PF_PAGE__NAME: - setName((String) newValue); - return; - case PageflowPackage.PF_PAGE__COMMENT: - setComment((String) newValue); - return; - case PageflowPackage.PF_PAGE__X: - setX(((Integer) newValue).intValue()); - return; - case PageflowPackage.PF_PAGE__Y: - setY(((Integer) newValue).intValue()); - return; - case PageflowPackage.PF_PAGE__WIDTH: - setWidth(((Integer) newValue).intValue()); - return; - case PageflowPackage.PF_PAGE__HEIGHT: - setHeight(((Integer) newValue).intValue()); - return; - case PageflowPackage.PF_PAGE__ID: - setId((String) newValue); - return; - case PageflowPackage.PF_PAGE__PAGEFLOW: - setPageflow((Pageflow) newValue); - return; - case PageflowPackage.PF_PAGE__OUTLINKS: - getOutlinks().clear(); - getOutlinks().addAll((Collection) newValue); - return; - case PageflowPackage.PF_PAGE__INLINKS: - getInlinks().clear(); - getInlinks().addAll((Collection) newValue); - return; - case PageflowPackage.PF_PAGE__PATH: - setPath((String) newValue); - return; - case PageflowPackage.PF_PAGE__SMALLICON: - setSmallicon((String) newValue); - return; - case PageflowPackage.PF_PAGE__LARGEICON: - setLargeicon((String) newValue); - return; - } - super.eSet(eFeature, newValue); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public void eUnset(EStructuralFeature eFeature) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case PageflowPackage.PF_PAGE__NAME: - setName(NAME_EDEFAULT); - return; - case PageflowPackage.PF_PAGE__COMMENT: - setComment(COMMENT_EDEFAULT); - return; - case PageflowPackage.PF_PAGE__X: - setX(X_EDEFAULT); - return; - case PageflowPackage.PF_PAGE__Y: - setY(Y_EDEFAULT); - return; - case PageflowPackage.PF_PAGE__WIDTH: - setWidth(WIDTH_EDEFAULT); - return; - case PageflowPackage.PF_PAGE__HEIGHT: - setHeight(HEIGHT_EDEFAULT); - return; - case PageflowPackage.PF_PAGE__ID: - setId(ID_EDEFAULT); - return; - case PageflowPackage.PF_PAGE__PAGEFLOW: - setPageflow((Pageflow) null); - return; - case PageflowPackage.PF_PAGE__OUTLINKS: - getOutlinks().clear(); - return; - case PageflowPackage.PF_PAGE__INLINKS: - getInlinks().clear(); - return; - case PageflowPackage.PF_PAGE__PATH: - setPath(PATH_EDEFAULT); - return; - case PageflowPackage.PF_PAGE__SMALLICON: - setSmallicon(SMALLICON_EDEFAULT); - return; - case PageflowPackage.PF_PAGE__LARGEICON: - setLargeicon(LARGEICON_EDEFAULT); - return; - } - super.eUnset(eFeature); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public boolean eIsSet(EStructuralFeature eFeature) { - switch (eDerivedStructuralFeatureID(eFeature)) { - case PageflowPackage.PF_PAGE__NAME: - return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT - .equals(name); - case PageflowPackage.PF_PAGE__COMMENT: - return COMMENT_EDEFAULT == null ? comment != null - : !COMMENT_EDEFAULT.equals(comment); - case PageflowPackage.PF_PAGE__X: - return x != X_EDEFAULT; - case PageflowPackage.PF_PAGE__Y: - return y != Y_EDEFAULT; - case PageflowPackage.PF_PAGE__WIDTH: - return width != WIDTH_EDEFAULT; - case PageflowPackage.PF_PAGE__HEIGHT: - return height != HEIGHT_EDEFAULT; - case PageflowPackage.PF_PAGE__ID: - return ID_EDEFAULT == null ? getId() != null : !ID_EDEFAULT - .equals(getId()); - case PageflowPackage.PF_PAGE__PAGEFLOW: - return getPageflow() != null; - case PageflowPackage.PF_PAGE__OUTLINKS: - return outlinks != null && !outlinks.isEmpty(); - case PageflowPackage.PF_PAGE__INLINKS: - return inlinks != null && !inlinks.isEmpty(); - case PageflowPackage.PF_PAGE__PATH: - return PATH_EDEFAULT == null ? getPath() != null : !PATH_EDEFAULT - .equals(getPath()); - case PageflowPackage.PF_PAGE__SMALLICON: - return SMALLICON_EDEFAULT == null ? getSmallicon() != null - : !SMALLICON_EDEFAULT.equals(getSmallicon()); - case PageflowPackage.PF_PAGE__LARGEICON: - return LARGEICON_EDEFAULT == null ? getLargeicon() != null - : !LARGEICON_EDEFAULT.equals(getLargeicon()); - } - return super.eIsSet(eFeature); - } - - /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - public String toString() { - if (eIsProxy()) - return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (path: "); - result.append(getPath()); - result.append(", smallicon: "); - result.append(getSmallicon()); - result.append(", largeicon: "); - result.append(getLargeicon()); - result.append(')'); - return result.toString(); - } - - public ReferenceElement getFCElements() { - - if (refElement == null) { - refElement = new PageReferenceElement(this); - } - return refElement; - } - -} -// PFPageImpl diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/ReferenceElement.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/ReferenceElement.java deleted file mode 100644 index 72e08e6f8..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/model/impl/ReferenceElement.java +++ /dev/null @@ -1,157 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement; -import org.eclipse.wst.common.internal.emf.resource.CompatibilityXMIResource; - -/** - * The base class for mapping facesconfig node from pageflow node. The - * ReferenceElement could be extended later to enable other model to be - * referenced by pageflow. - * - * @author hmeng - * - */ -public abstract class ReferenceElement { - - private List data = new ArrayList(); - - protected PageflowElement pageflowElement; - - public ReferenceElement(PageflowElement pageflowElement) { - this.pageflowElement = pageflowElement; - } - - public ReferenceElement(PageflowElement pageflowElement, - EObject facesConfigObject) { - this(pageflowElement); - this.add(facesConfigObject); - } - - /** - * Add object to the list. - * - * @param object - */ - public void add(EObject object) { - if (!data.contains(object)) { - data.add(object); - } - } - - public boolean contains(EObject object) { - return data.contains(object); - } - - /** - * The fragment path of a node. - * - * @param object - * @return the path - */ - public static String resolvePath(EObject object) { - if (object != null) { - ((CompatibilityXMIResource) object.eResource()) - .setFormat(CompatibilityXMIResource.FORMAT_EMF1); - String uriTarget = object.eResource().getURIFragment(object); - return uriTarget; - } - return ""; - } - - public boolean remove(EObject object) { - boolean result = data.remove(object); - return result; - } - - /** - * Resolve each referenced data's path and combine the result into one - * string, the path will be seperated with '|'. - * - * @return the resolved string - */ - public String resolveReferenceString() { - String result = ""; - for (int i = 0, n = data.size(); i < n; i++) { - result += resolvePath((EObject) data.get(i)) + "|"; - } - if (result.length() > 0) { - result = result.substring(0, result.length()); - } - return result; - } - - /** - * The EMF paths of all referenced elements. - * - * @return the list of resolved paths for the data elements - */ - public List getPaths() { - List paths = new ArrayList(); - for (int i = 0, n = data.size(); i < n; i++) { - paths.add(resolvePath((EObject) data.get(i))); - } - return paths; - } - - /** - * The facesconfig elements that are referenced. - * - * @return the list of elements - */ - public List getData() { - return data; - } - - public void clear() { - if (!data.isEmpty()) { - data.clear(); - } - } - - public boolean isEmpty() { - return data.isEmpty(); - } - - public void dispose() { - clear(); - } - - /** - * Update the referenced faces-config elements. - * - */ - abstract public void update(); - - /** - * Return a pageflow property's value with referenced faces-config element. - * - * @param eFeature - * @return the value for eFeature - */ - abstract public Object get(int eFeature); - - /** - * To set a pageflow property's value will result in seting a faces-config - * element. - * - * @param eFeature - * @param newValue - */ - abstract public void set(EStructuralFeature eFeature, Object newValue); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ActionDialogCellEditor.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ActionDialogCellEditor.java deleted file mode 100644 index 4b8ec9b92..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ActionDialogCellEditor.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties; - -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; - -/** - * - * Dialog Cell Editor for Action browser. - * - * @author Xiao-guang Zhang - */ -public class ActionDialogCellEditor extends EditableDialogCellEditor { - - /* - * (non-Javadoc) - * - * @see DialogCellEditor#DialogCellEditor() - */ - public ActionDialogCellEditor() { - super(); - } - - /* - * (non-Javadoc) - * - * @see DialogCellEditor#DialogCellEditor(Composite parent) - */ - public ActionDialogCellEditor(Composite parent) { - super(parent); - } - - /* - * (non-Javadoc) - * - * @see DialogCellEditor#DialogCellEditor(Composite parent, int style) - */ - public ActionDialogCellEditor(Composite parent, int style) { - super(parent, style); - } - - /* - * (non-Javadoc) - * - * @see DialogCellEditor#openDialogBox(org.eclipse.swt.widgets.Control) - */ - protected Object openDialogBox(Control cellEditorWindow) { - String actionExpression = getDefaultText().getText(); - // IStructuredSelection selectionToPass = StructuredSelection.EMPTY; - // Create a new jsf Wizard - - // FIXME sfshi 2005-11-16 - // ActionSelectionWizard actionSelectionWizard = - // new ActionSelectionWizard(ActionSelectionWizard.CONSIDER_METHODS); - // actionSelectionWizard.init(EditorPlugin.getDefault().getWorkbench(), - // selectionToPass); - // actionSelectionWizard.setActionExpression(actionExpression); - // //using a wizard dialog to display the new jsf wizard - // WizardDialog actionSelectionWizardDialog = - // new WizardDialog(cellEditorWindow.getShell(),actionSelectionWizard); - // if (actionSelectionWizardDialog.open() == WizardDialog.OK ) - // { - // actionExpression = actionSelectionWizard.getActionExpression(); - // } - return actionExpression; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ActionOutcomeDialogCellEditor.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ActionOutcomeDialogCellEditor.java deleted file mode 100644 index e24b2adf3..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ActionOutcomeDialogCellEditor.java +++ /dev/null @@ -1,105 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties; - -import org.eclipse.jface.window.Window; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode; -import org.eclipse.jst.jsf.facesconfig.ui.util.WebrootUtil; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; - -/** - * - * Dialog Cell Editor for Action's outcome browser. - * - * @author Xiao-guang Zhang - */ -public class ActionOutcomeDialogCellEditor extends EditableDialogCellEditor { - /** the source PFLink element */ - PageflowElement element; - - /* - * (non-Javadoc) - * - * @see DialogCellEditor#DialogCellEditor() - */ - public ActionOutcomeDialogCellEditor(PageflowElement element) { - super(); - this.element = element; - } - - /* - * (non-Javadoc) - * - * @see DialogCellEditor#DialogCellEditor(Composite parent) - */ - public ActionOutcomeDialogCellEditor(Composite parent, - PageflowElement element) { - super(parent); - this.element = element; - } - - /* - * (non-Javadoc) - * - * @see DialogCellEditor#DialogCellEditor(Composite parent, int style) - */ - public ActionOutcomeDialogCellEditor(Composite parent, int style, - PageflowElement element) { - super(parent, style); - this.element = element; - } - - /** - * get the previous JSP page, it can be null if the previous node is not - * PFPage, but PFAction. - * - * @param element_ - * @return - */ - private String getPreviousJSPPath(PageflowElement element_) { - String jspPath = null; - if (element_ instanceof PageflowLink) { - PageflowNode source = ((PageflowLink) element_).getSource(); - - if (source instanceof PageflowPage) { - jspPath = ((PageflowPage) source).getPath(); - } - } - return jspPath; - } - - /* - * (non-Javadoc) - * - * @see DialogCellEditor#openDialogBox(org.eclipse.swt.widgets.Control) - */ - protected Object openDialogBox(Control cellEditorWindow) { - String outcome = getDefaultText().getText(); - - String jspPathName = WebrootUtil.getProjectPath(element, - getPreviousJSPPath(element)); - - ActionOutcomeSelectionDialog selectionDialog = new ActionOutcomeSelectionDialog( - getControl().getShell(), outcome, jspPathName); - - if (selectionDialog.open() == Window.OK) { - outcome = selectionDialog.getSelectedAction(); - } - - return outcome; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ActionOutcomeSelectionDialog.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ActionOutcomeSelectionDialog.java deleted file mode 100644 index 3a6309774..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ActionOutcomeSelectionDialog.java +++ /dev/null @@ -1,367 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties; - -import java.util.List; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.viewers.ColumnPixelData; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.Separator; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowMessages; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.util.JSPUtil; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.TableItem; -import org.eclipse.swt.widgets.Text; -import org.w3c.dom.Attr; -import org.w3c.dom.Element; - -/** - * This dialog is used to edit outcome property of link component of Pageflow - * Designer. - * - * @author Xiao-guang Zhang - */ -public class ActionOutcomeSelectionDialog extends Dialog { - - /** property's name text control */ - private Text actionText; - - /** linked source jsp file name */ - private String jspName; - - /** the current outcome */ - private String outcome; - - /** action table control */ - private Table actionTable; - - /** Column width of component name and action */ - private static final int COMPONENT_COL_WIDTH = 160; - - private static final int ACTION_COL_WIDTH = 160; - - /** Dialog default height and width */ - private static final int DIALOG_DEFAULT_WIDTH = 400; - - private static final int DIALOG_DEFAULT_HEIGHT = 300; - - public static String JSF_EL_LEFT_BRACE = "#{"; - - public static String JSF_EL_RIGHT_BRACE = "}"; - - /** the listener for the text modification */ - private ModifyListener modifyListener; - - public ActionOutcomeSelectionDialog(Shell parentShell, String outcome, - String jspName) { - super(parentShell); - this.outcome = outcome; - this.jspName = jspName; - - modifyListener = new ModifyListener() { - public void modifyText(ModifyEvent e) { - verifyComplete(); - } - }; - } - - /* - * (non-Javadoc) - * - * @see Dialog#createDialogArea(Composite) - */ - protected Control createDialogArea(Composite parent) { - GridLayout gridLayout; - - Composite container = (Composite) super.createDialogArea(parent); - gridLayout = new GridLayout(); - gridLayout.numColumns = 1; - gridLayout.marginWidth = 10; - gridLayout.marginHeight = 10; - container.setLayout(gridLayout); - GridData gd = new GridData(GridData.FILL_BOTH); - // gd.widthHint = 300; - gd.heightHint = DIALOG_DEFAULT_HEIGHT; - gd.widthHint = DIALOG_DEFAULT_WIDTH; - container.setLayoutData(gd); - - Label choiceLabel = new Label(container, SWT.LEFT); - gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - // gd.widthHint = 100; - choiceLabel.setLayoutData(gd); - // Pageflow.Property.Action.OutcomeSelectionDialog.Choice = Enter the - // outcome or select one from action list below: - choiceLabel - .setText(PageflowMessages.Pageflow_Property_Action_OutcomeSelectionDialog_Choice); - - createOutcomeSection(container); - - createActionListSection(container); - - return container; - } - - /** - * create a Outcome input section - * - * @param container - */ - protected void createOutcomeSection(Composite container) { - Composite outcomeSection = new Composite(container, SWT.NONE); - GridLayout gl = new GridLayout(); - gl.numColumns = 1; - gl.marginWidth = 0; - outcomeSection.setLayout(gl); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - outcomeSection.setLayoutData(gd); - - actionText = new Text(outcomeSection, SWT.BORDER); - gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL - | GridData.FILL_HORIZONTAL); - actionText.setLayoutData(gd); - - actionText.addModifyListener(modifyListener); - - if (outcome != null && outcome.length() > 0) { - actionText.setText(outcome); - } - } - - /** - * create action list table section - * - * @param container - */ - protected void createActionListSection(Composite container) { - final Group actionSection = new Group(container, SWT.NONE); - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 1; - actionSection.setLayout(gridLayout); - GridData gd = new GridData(GridData.FILL_BOTH); - actionSection.setLayoutData(gd); - - String actionListTitle = PageflowMessages.Pageflow_Property_Action_OutcomeSelectionDialog_ActionListTable_Title;//$NON-NLS-1$ - - if (jspName != null && jspName.length() > 0) { - actionListTitle += " in " + jspName; - } - // Pageflow.Property.Action.OutcomeSelectionDialog.ActionListTable.Title - // = Actions - actionSection.setText(actionListTitle); - - actionTable = new Table(actionSection, SWT.BORDER | SWT.FULL_SELECTION); - actionTable.setLayoutData(new GridData(GridData.FILL_BOTH)); - actionTable.setHeaderVisible(true); - actionTable.setLinesVisible(true); - TableLayout layout = new TableLayout(); - actionTable.setLayout(layout); - - layout.addColumnData(new ColumnPixelData(COMPONENT_COL_WIDTH)); - layout.addColumnData(new ColumnPixelData(ACTION_COL_WIDTH)); - TableColumn componentCol = new TableColumn(actionTable, SWT.NONE); - // Pageflow.Property.Action.OutcomeSelectionDialog.ActionListTable.Component - // = Component ID - componentCol - .setText(PageflowMessages.Pageflow_Property_Action_OutcomeSelectionDialog_ActionListTable_Component); //$NON-NLS-1$ - TableColumn actionCol = new TableColumn(actionTable, SWT.NONE); - - // Pageflow.Property.Action.OutcomeSelectionDialog.ActionListTable.Action - // = Action - actionCol - .setText(PageflowMessages.Pageflow_Property_Action_OutcomeSelectionDialog_ActionListTable_Action);//$NON-NLS-1$ - - actionTable.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - TableItem selItem = (TableItem) e.item; - String action = selItem.getText(1); - if (action != null && action.length() > 0) - actionText.setText(action); - } - }); - - addActionsInJSP(); - - } - - /** - * 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(null, - composite, nColumns, convertHeightInCharsToPixels(1)); - } - - /* - * (non-Javadoc) - * - * @see Dialog#createButtonsForButtonBar(Composite) - */ - protected void createButtonsForButtonBar(Composite parent) { - createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, - true); - createButton(parent, IDialogConstants.CANCEL_ID, - IDialogConstants.CANCEL_LABEL, false); - - verifyComplete(); - } - - /* - * (non-Javadoc) - * - * @see Dialog#configureShell(Shell) - */ - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - - // Pageflow.Property.Action.OutcomeSelectionDialog.Title = Outcome - // Selection - newShell - .setText(PageflowMessages.Pageflow_Property_Action_OutcomeSelectionDialog_Title); //$NON-NLS-1$ - - } - - /* - * (non-Javadoc) - * - * @see Dialog#buttonPressed(int) - */ - protected void buttonPressed(int buttonId) { - if (buttonId == IDialogConstants.CANCEL_ID) { - setReturnCode(CANCEL); - close(); - return; - } else if (buttonId == IDialogConstants.OK_ID) { - setReturnCode(OK); - - outcome = actionText.getText(); - - close(); - return; - } - super.buttonPressed(buttonId); - } - - /** - * - * check the dialog inputs are complete or not, and set the OK button enable - * or not. - */ - private void verifyComplete() { - if (getButton(IDialogConstants.OK_ID) != null) { - getButton(IDialogConstants.OK_ID).setEnabled(isDialogComplete()); - } - } - - /** - * check the dialog inputs are complete or not. - * - * @return - */ - private boolean isDialogComplete() { - return isValidName(); - } - - /** - * the input name is valid or not - * - * @return - */ - private boolean isValidName() { - return actionText.getText().length() > 0; - } - - /** - * get the selected action in the action table - * - * @return - selected action - */ - public String getSelectedAction() { - return outcome; - } - - /** - * add actions in the source jsp file to the action list table control - * - */ - private void addActionsInJSP() { - List actionNodes = JSPUtil.getActionListInJSPFile(jspName); - - if (actionNodes != null) { - for (int i = 0, n = actionNodes.size(); i < n; i++) { - Element node = (Element) actionNodes.get(i); - StringBuffer componentName = new StringBuffer(); - - Attr idAttr = node.getAttributeNode("id"); - if (idAttr != null) - componentName.append(idAttr.getNodeValue()); - - componentName.append("(").append(node.getTagName()).append(")"); //$NON-NLS-1$ - - Attr actionAttr = node.getAttributeNode("action"); - if (actionAttr != null) { - String action = actionAttr.getValue(); - if (isValidEL(action)) - addActionTableItem(componentName.toString(), action); - } - } - } - } - - public static boolean isValidEL(String expressionString) { - if (expressionString == null || expressionString.length() == 0) - return true; - - return (expressionString.startsWith(JSF_EL_LEFT_BRACE) && expressionString - .endsWith(JSF_EL_RIGHT_BRACE)) - || (!expressionString.startsWith(JSF_EL_LEFT_BRACE) && !expressionString - .endsWith(JSF_EL_RIGHT_BRACE)); - } - - /** - * add a new action item in the previous jsp page. - * - * @param componentName - - * JSF component element - * @param action - - * value of action's attribute - */ - private void addActionTableItem(String componentName, String action) { - if (componentName != null && componentName.length() > 0 - && action != null && action.length() > 0) { - TableItem item = new TableItem(actionTable, SWT.NONE); - item.setText(0, componentName); - item.setText(1, action); - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ActionSectionDescriptor.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ActionSectionDescriptor.java deleted file mode 100644 index 217366634..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ActionSectionDescriptor.java +++ /dev/null @@ -1,11 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2006 Oracle Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties; diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/EditableDialogCellEditor.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/EditableDialogCellEditor.java deleted file mode 100644 index 18f6c7770..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/EditableDialogCellEditor.java +++ /dev/null @@ -1,144 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties; - -import java.text.MessageFormat; - -import org.eclipse.jface.viewers.DialogCellEditor; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.FocusAdapter; -import org.eclipse.swt.events.FocusEvent; -import org.eclipse.swt.events.KeyAdapter; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Text; - -/** - * @author Hong-tao Meng - */ -public abstract class EditableDialogCellEditor extends DialogCellEditor { - private Text text; - - /** - * - */ - public EditableDialogCellEditor() { - super(); - } - - /** - * @param parent - */ - public EditableDialogCellEditor(Composite parent) { - super(parent); - } - - /** - * @param parent - * @param style - */ - public EditableDialogCellEditor(Composite parent, int style) { - super(parent, style); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.DialogCellEditor#createContents(org.eclipse.swt.widgets.Composite) - */ - protected Control createContents(Composite cell) { - text = new Text(cell, SWT.LEFT); - text.setFont(cell.getFont()); - text.setBackground(cell.getBackground()); - text.addKeyListener(new KeyAdapter() { - // hook key pressed - see PR 14201 - public void keyPressed(KeyEvent e) { - keyReleaseOccured(e); - // disposed this cell editor - if ((getControl() == null) || getControl().isDisposed()) { - return; - } - } - }); - // when the text control has focus, the cellEditor will deactive even - // when you press the button. - // Add the follow codes enable switch to the button control. - text.addFocusListener(new FocusAdapter() { - public void focusLost(FocusEvent e) { - boolean newValidState = isCorrect(text.getText()); - if (newValidState) { - markDirty(); - doSetValue(text.getText()); - } else { - // try to insert the current value into the error message. - setErrorMessage(MessageFormat.format(getErrorMessage(), - new Object[] { text.getText().toString() })); - } - } - }); - - return text; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.CellEditor#doSetFocus() - */ - protected void doSetFocus() { - text.setFocus(); - text.selectAll(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.DialogCellEditor#updateContents(java.lang.Object) - */ - protected void updateContents(Object value) { - if (text == null) { - return; - } - - String text_ = "";//$NON-NLS-1$ - if (value != null) { - text_ = value.toString(); - } - this.text.setText(text_); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.CellEditor#keyReleaseOccured(org.eclipse.swt.events.KeyEvent) - */ - protected void keyReleaseOccured(KeyEvent keyEvent) { - if (keyEvent.character == '\r') { - boolean newValidState = isCorrect(text.getText()); - if (newValidState) { - markDirty(); - doSetValue(text.getText()); - } else { - // try to insert the current value into the error message. - setErrorMessage(MessageFormat.format(getErrorMessage(), - new Object[] { text.getText().toString() })); - } - fireApplyEditorValue(); - } - super.keyReleaseOccured(keyEvent); - } - - public Text getDefaultText() { - return text; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/EditorSectionDescriptor.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/EditorSectionDescriptor.java deleted file mode 100644 index f0d6442e1..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/EditorSectionDescriptor.java +++ /dev/null @@ -1,116 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties; - -import java.util.List; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowEditPart; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.section.EditorSection; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.wst.common.ui.properties.internal.provisional.ISection; -import org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor; -import org.eclipse.wst.common.ui.properties.internal.provisional.ITypeMapper; - - - -/** - * @author jchoi - */ -public class EditorSectionDescriptor implements ISectionDescriptor { - /** - * constructor - */ - public EditorSectionDescriptor() { - super(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getId() - */ - public String getId() { - return ITabbedPropertiesConstants.EDITOR_SECTION; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getFilter() - */ - public ITypeMapper getFilter() { - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getInputTypes() - */ - public List getInputTypes() { - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getSectionClass() - */ - public ISection getSectionClass() { - return new EditorSection(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getTargetTab() - */ - public String getTargetTab() { - return ITabbedPropertiesConstants.ATTRIBUTE_TAB_ID; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#appliesTo(org.eclipse.ui.IWorkbenchPart, - * org.eclipse.jface.viewers.ISelection) - */ - public boolean appliesTo(IWorkbenchPart part, ISelection selection) { - Object object = null; - if (selection instanceof StructuredSelection) { - StructuredSelection structuredSelection = (StructuredSelection) selection; - object = structuredSelection.getFirstElement(); - // The editor section in the attribute tab will be shown for only - // pageflow element - if (object instanceof PageflowEditPart) { - return true; - } - } - return false; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getAfterSection() - */ - public String getAfterSection() { - return ITabbedPropertiesConstants.TOP_SECTION; - } - - public int getEnablesFor() { - // TODO Auto-generated method stub - return ENABLES_FOR_ANY; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ExistingPagePathDialogCellEditor.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ExistingPagePathDialogCellEditor.java deleted file mode 100644 index 2a5e27dc1..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ExistingPagePathDialogCellEditor.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.eclipse.jface.window.Window; -import org.eclipse.jst.jsf.facesconfig.ui.dialog.ListChoiceDialog; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowMessages; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; - -/** - * The cell editor used to locate an existing pageflow page node in current - * pageflow. - * - * @author hmeng - * - */ -public class ExistingPagePathDialogCellEditor extends EditableDialogCellEditor { - Pageflow pageflow; - - public ExistingPagePathDialogCellEditor() { - super(); - // TODO Auto-generated constructor stub - } - - public ExistingPagePathDialogCellEditor(Composite parent, int style) { - super(parent, style); - // TODO Auto-generated constructor stub - } - - public ExistingPagePathDialogCellEditor(Composite parent, Pageflow pageflow) { - super(parent); - this.pageflow = pageflow; - } - - /* - * (non-Javadoc) - * - * @see DialogCellEditor#openDialogBox(Control) - */ - protected Object openDialogBox(Control cellEditorWindow) { - String jsfSelection = ""; - if (getDefaultText() != null && getDefaultText().getText().length() > 0) { - jsfSelection = getDefaultText().getText(); - } - ListChoiceDialog dialog = new ListChoiceDialog(cellEditorWindow - .getShell(), getPagePaths(), - PageflowMessages.ExistingPagePathDialogCellEdito_LabelText); - - if (dialog.open() == Window.OK) { - jsfSelection = dialog.getResult(); - } - return jsfSelection; - } - - /** - * Collect page paths in current pageflow. - * - * @return - */ - private String[] getPagePaths() { - List result = new ArrayList(); - List list = pageflow.getNodes(); - for (int i = 0; i < list.size(); i++) { - String path = ((PageflowPage) list.get(i)).getPath(); - if (path != null && path.trim().length() > 0) { - result.add(path); - } - } - String[] r = (String[]) result.toArray(new String[result.size()]); - Arrays.sort(r); - return r; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/GeneralViewSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/GeneralViewSection.java deleted file mode 100644 index 7ebd1e133..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/GeneralViewSection.java +++ /dev/null @@ -1,375 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.part.MultiPageEditorPart; -import org.eclipse.ui.part.PageBook; -import org.eclipse.ui.views.properties.IPropertySheetPage; -import org.eclipse.ui.views.properties.PropertySheetPage; -import org.eclipse.wst.common.ui.properties.internal.provisional.ISection; -import org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertyConstants; -import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetPage; -import org.eclipse.wst.sse.ui.StructuredTextEditor; - -/** - * This class defines the general tab for pageflow attributes. This class - * defines the controls shown in this sectin and their event handler. For - * MultiPageEditorPart, if it support getAdapter(IEditorPart.class) to get the - * current active editor, then, this section can get the different - * PropertySheetPage for different sub EditorPart. - * - * @author Xiao-guang Zhang - */ -public class GeneralViewSection implements ISection, - ISelectionChangedListener { - /** the pagebook */ - private PageBook pageBook = null; - - /** - * A data structure used to store the information about a single page within - * a MultiPageEditorPart - */ - protected static class PageRec { - - /** - * The part including editorpart, or Control - */ - public IWorkbenchPart part; - - /** - * The page. - */ - public IPropertySheetPage page; - - /** - * Creates a new page record initialized to the given part and page. - * - * @param part - * @param page - */ - public PageRec(IWorkbenchPart part, IPropertySheetPage page) { - this.part = part; - this.page = page; - } - - /** - * Disposes of this page record by <code>null</code>ing its fields. - */ - public void dispose() { - part = null; - page = null; - } - } - - /** - * Map from parts to part records (key type: <code>IWorkbenchPart</code>; - * value type: <code>PartRec</code>). - */ - private Map mapPartToRec = new HashMap(); - - /** - * The page record for the default page. - */ - private PageRec defaultPageRec; - - /** - * The page rec which provided the current page or <code>null</code> - */ - private PageRec activeRec; - - /* - * (non-Javadoc) - * - * @see com.createControls(Composite, TabbedPropertySheetPage) - */ - public void createControls(Composite parent, - TabbedPropertySheetPage tabbedPropertySheetPage) { - FillLayout layout = new FillLayout(); - layout.marginWidth = ITabbedPropertyConstants.HSPACE; - layout.marginHeight = ITabbedPropertyConstants.VSPACE; - - // composite.setLayout(layout); - parent.setLayout(layout); - // pagebook - pageBook = new PageBook(parent, SWT.BORDER); - - // create a default property page. - createDefaultPage(); - - // Show the default page - if (defaultPageRec != null) { - showPageRec(defaultPageRec); - } - } - - /** - * Shows page contained in the given page record in this view. The page - * record must be one from this pagebook view. - * <p> - * The <code>PageBookView</code> implementation of this method asks the - * pagebook control to show the given page's control, and records that the - * given page is now current. Subclasses may extend. - * </p> - * - * @param pageRec - * the page record containing the page to show - */ - protected void showPageRec(PageRec pageRec) { - // If already showing do nothing - if (activeRec == pageRec) { - return; - } - // If the page is the same, just set activeRec to pageRec - if (activeRec != null && pageRec != null - && activeRec.page == pageRec.page) { - activeRec = pageRec; - return; - } - - // Show new page. - activeRec = pageRec; - Control pageControl = activeRec.page.getControl(); - if (pageControl != null && !pageControl.isDisposed()) { - // Verify that the page control is not disposed - // If we are closing, it may have already been disposed - pageBook.showPage(pageControl); - } - } - - /** - * Creates a page for a given part. Adds it to the pagebook but does not - * show it. - * - * @param part - * The part we are making a page for. - * @return IWorkbenchPart - */ - private PageRec createPage(IWorkbenchPart part) { - PageRec rec = doCreatePage(part); - if (rec != null) { - mapPartToRec.put(part, rec); - } - return rec; - } - - /* - * (non-Javadoc) Method declared on PageBookView. - */ - protected PageRec doCreatePage(IWorkbenchPart part) { - // FIXME: Because the PropertySheetPage of StructuredTextEditor has a - // bug: - // the editor can't be opened twice if the property view is shown. - // This bug only exists in WTP 1.0.0 version. - if (part instanceof StructuredTextEditor) { - return null; - } - // Try to get an property page. - Object obj = part.getAdapter(IPropertySheetPage.class); - if (obj instanceof IPropertySheetPage) { - IPropertySheetPage page = (IPropertySheetPage) obj; - - page.createControl(getPageBook()); - - return new PageRec(part, page); - } - // There is no content property page - return null; - } - - private void createDefaultPage() { - // Create the default PropertySheetPage rec. - IPropertySheetPage defaultPage = new PropertySheetPage(); - defaultPage.createControl(getPageBook()); - - defaultPageRec = new PageRec(null, defaultPage); - } - - /** - * Returns the pagebook control for this view. - * - * @return the pagebook control, or <code>null</code> if not initialized - */ - protected PageBook getPageBook() { - return pageBook; - } - - /** - * Returns the page record for the given part. - * - * @param part - * the part - * @return the corresponding page record, or <code>null</code> if not - * found - */ - protected PageRec getPageRec(Object part) { - return (PageRec) mapPartToRec.get(part); - } - - /* - * (non-Javadoc) - * - * @see ISection#setInput(IWorkbenchPart, ISelection) - */ - public void setInput(IWorkbenchPart part, ISelection selection) { - if (part instanceof MultiPageEditorPart) { - IEditorPart subPage = (IEditorPart) part - .getAdapter(IEditorPart.class); - if (subPage != null) { - // get or Create a PropertySheetPage for the part. - PageRec rec = getPageRec(subPage); - if (rec == null) { - rec = createPage(subPage); - } - - // Show the page. - if (rec != null) { - showPageRec(rec); - } else { - showPageRec(defaultPageRec); - } - } - } - activeRec.page.selectionChanged(part, selection); - } - - /* - * (non-Javadoc) - * - * @see ISection#aboutToBeShown() - */ - public void aboutToBeShown() { - refresh(); - } - - /* - * (non-Javadoc) - * - * @see ISection#aboutToBeHidden() - */ - public void aboutToBeHidden() { - // do nothing - } - - /* - * (non-Javadoc) - * - * @see ISection#dispose() - */ - public void dispose() { - // Deref all of the pages. - activeRec = null; - if (defaultPageRec != null) { - // check for null since the default page may not have - // been created (ex. perspective never visible) - defaultPageRec.page.dispose(); - defaultPageRec = null; - } - Map clone = (Map) ((HashMap) mapPartToRec).clone(); - Iterator iter = clone.values().iterator(); - while (iter.hasNext()) { - PageRec rec = (PageRec) iter.next(); - removePage(rec); - } - } - - /** - * Removes a page record. If it is the last reference to the page dispose of - * it - otherwise just decrement the reference count. - * - * @param rec - */ - private void removePage(PageRec rec) { - mapPartToRec.remove(rec.part); - - Control control = rec.page.getControl(); - if (control != null && !control.isDisposed()) { - // Dispose the page's control so pages don't have to do this in - // their - // dispose method. - // The page's control is a child of this view's control so if this - // view - // is closed, the page's control will already be disposed. - control.dispose(); - } - - // free the page - doDestroyPage(rec.part, rec); - } - - /** - * Destroys a page in the pagebook for a particular part. - * - * @param part - * the input part - * @param rec - * a page record for the part - */ - protected void doDestroyPage(IWorkbenchPart part, PageRec rec) { - IPropertySheetPage page = rec.page; - page.dispose(); - rec.dispose(); - } - - /* - * (non-Javadoc) - * - * @see ISection#getMinimumHeight() - */ - public int getMinimumHeight() { - return SWT.DEFAULT; - } - - /* - * (non-Javadoc) - * - * @see com.ibm.xtools.common.ui.properties.ISection#shouldUseExtraSpace() - */ - public boolean shouldUseExtraSpace() { - /** - * here should return true, otherwise, the component controls will not - * fill the whole panel of the tab. - */ - return true; - } - - /* - * (non-Javadoc) - * - * @see com.ibm.xtools.common.ui.properties.ISection#refresh() - */ - public void refresh() { - return; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) - */ - public void selectionChanged(SelectionChangedEvent event) { - setInput((IWorkbenchPart) event.getSource(), event.getSelection()); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/GeneralViewSectionDescriptor.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/GeneralViewSectionDescriptor.java deleted file mode 100644 index 51e42532c..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/GeneralViewSectionDescriptor.java +++ /dev/null @@ -1,134 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties; - -import java.util.List; - -import org.eclipse.jface.text.ITextSelection; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowElementEditPart; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowElementTreeEditPart; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowLinkEditPart; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.util.PageflowValidation; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.wst.common.ui.properties.internal.provisional.ISection; -import org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor; -import org.eclipse.wst.common.ui.properties.internal.provisional.ITypeMapper; - -/** - * This class defines the section descriptor for pageflow attributes. Following - * is the typical function of SectionDescriptor for tabbed property views. 1. In - * tabbed property view, there are multiple sections, one or more than one - * sections can be composed of one tab. 2. Each of section has an ID, and their - * relationship is defined by the function "getAfterSection". 3. Not all - * sections are enabled always. They are enabled according to current - * WorkbenchPart and selection, which is defined in function "appliesTo". - * - * @author Xiao-guang Zhang - */ -public class GeneralViewSectionDescriptor implements ISectionDescriptor { - - /* - * (non-Javadoc) - * - * @see ISectionDescriptor#getId() - */ - public String getId() { - return ITabbedPropertiesConstants.GENERAL_TAB_ID; - } - - /* - * (non-Javadoc) - * - * @see ISectionDescriptor#getFilter() - */ - public ITypeMapper getFilter() { - return null; - } - - /* - * (non-Javadoc) - * - * @see ISectionDescriptor#getInputTypes() - */ - public List getInputTypes() { - return null; - } - - /* - * (non-Javadoc) - * - * @see ISectionDescriptor#getSectionClass() - */ - public ISection getSectionClass() { - return new GeneralViewSection(); - } - - /* - * (non-Javadoc) - * - * @see com.ibm.xtools.common.ui.properties.ISectionDescriptor#getTargetTab() - */ - public String getTargetTab() { - return ITabbedPropertiesConstants.GENERAL_TAB_ID; - } - - /* - * (non-Javadoc) - * - * @see ISectionDescriptor#appliesTo(IWorkbenchPart, ISelection) - */ - public boolean appliesTo(IWorkbenchPart part, ISelection selection) { - Object object = null; - // FIXME: Should move the appliesTo to differnt page of - // MultiPageEditorPart. - if (selection instanceof StructuredSelection) { - StructuredSelection structuredSelection = (StructuredSelection) selection; - object = structuredSelection.getFirstElement(); - // The general tab will be shown for only pageflow element and - // pageflow link editparts - if (object instanceof PageflowElementEditPart - || object instanceof PageflowElementTreeEditPart) { - return true; - } else if (object instanceof PageflowLinkEditPart) { - PageflowLink pfLink = (PageflowLink) ((PageflowLinkEditPart) object) - .getModel(); - if (PageflowValidation.getInstance().isValidLinkForProperty( - pfLink)) { - return true; - } - } else { - return true; - } - } else if (selection instanceof ITextSelection) { - return true; - } - - return false; - } - - /* - * (non-Javadoc) - * - * @see ISectionDescriptor#getAfterSection() - */ - public String getAfterSection() { - return ""; - } - - public int getEnablesFor() { - return ENABLES_FOR_ANY; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ITabbedPropertiesConstants.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ITabbedPropertiesConstants.java deleted file mode 100644 index a365f8655..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ITabbedPropertiesConstants.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties; - -/** - * @author jchoi - * @version - */ -public interface ITabbedPropertiesConstants { - public static int BROWSE_HEIGHT = 18; - - public static int BROWSE_WIDTH = 20; - - public static final String GENERAL_TAB_ID = "org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.general"; - - public static final String ATTRIBUTE_TAB_ID = "org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.attribute"; - - public static final String OPTIONAL_SECTION = "attribute.optional"; // 5 - - public static final String COMMON_SECTION = "attribute.optional"; // 5 - - public static final String LINK_SECTION = "attribute.link"; // 4 - - public static final String PAGE_SECTION = "attribute.page"; // 3 - - public static final String ACTION_SECTION = "attribute.action"; // 1 - - public static final String EDITOR_SECTION = "attribute.editor"; // 1 - - public static final String TOP_SECTION = "top"; // 0 - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/LinkSectionDescriptor.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/LinkSectionDescriptor.java deleted file mode 100644 index 14aa8b0f7..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/LinkSectionDescriptor.java +++ /dev/null @@ -1,116 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties; - -import java.util.List; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowLinkEditPart; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.section.LinkSection; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.util.PageflowValidation; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.wst.common.ui.properties.internal.provisional.ISection; -import org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor; -import org.eclipse.wst.common.ui.properties.internal.provisional.ITypeMapper; - -/** - * @author jchoi - * @version - */ -public class LinkSectionDescriptor implements ISectionDescriptor { - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getId() - */ - public String getId() { - return ITabbedPropertiesConstants.LINK_SECTION; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getFilter() - */ - public ITypeMapper getFilter() { - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getInputTypes() - */ - public List getInputTypes() { - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getSectionClass() - */ - public ISection getSectionClass() { - return new LinkSection(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getTargetTab() - */ - public String getTargetTab() { - return ITabbedPropertiesConstants.ATTRIBUTE_TAB_ID; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#appliesTo(org.eclipse.ui.IWorkbenchPart, - * org.eclipse.jface.viewers.ISelection) - */ - public boolean appliesTo(IWorkbenchPart part, ISelection selection) { - Object object = null; - if (selection instanceof StructuredSelection) { - StructuredSelection structuredSelection = (StructuredSelection) selection; - object = structuredSelection.getFirstElement(); - if (object instanceof PageflowLinkEditPart) { - PageflowLink pfLink = (PageflowLink) ((PageflowLinkEditPart) object).getModel(); - if (PageflowValidation.getInstance().isValidLinkForProperty( - pfLink)) { - - return true; - } - - } - } - return false; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getAfterSection() - */ - public String getAfterSection() { - return ITabbedPropertiesConstants.TOP_SECTION; - } - - public int getEnablesFor() { - // TODO Auto-generated method stub - return ENABLES_FOR_ANY; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PagePathDialogCellEditor.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PagePathDialogCellEditor.java deleted file mode 100644 index d3a0b13f4..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PagePathDialogCellEditor.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jface.window.Window; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; -import org.eclipse.jst.jsf.facesconfig.ui.util.WebrootUtil; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; - -/** - * Dialog Cell Editor for Page path browser. - * - * @author Xiao-guang Zhang - */ -public class PagePathDialogCellEditor extends EditableDialogCellEditor { - PageflowPage element; - - /* - * (non-Javadoc) - * - * @see DialogCellEditor#DialogCellEditor() - */ - public PagePathDialogCellEditor() { - super(); - } - - /* - * (non-Javadoc) - * - * @see DialogCellEditor#DialogCellEditor(Composite parent) - */ - public PagePathDialogCellEditor(Composite parent, PageflowPage element) { - super(parent); - this.element = element; - } - - /* - * (non-Javadoc) - * - * @see DialogCellEditor#DialogCellEditor(Composite parent, int style) - */ - public PagePathDialogCellEditor(Composite parent, int style) { - super(parent, style); - } - - /* - * (non-Javadoc) - * - * @see DialogCellEditor#openDialogBox(Control) - */ - protected Object openDialogBox(Control cellEditorWindow) { - String jsfSelection = ""; - if (getDefaultText() != null && getDefaultText().getText().length() > 0) { - jsfSelection = getDefaultText().getText(); - IProject project = WebrootUtil.getProject(element); - ProjectWebPageSelectionDialog dlg = new ProjectWebPageSelectionDialog( - cellEditorWindow.getShell(), project); - if (dlg.open() == Window.OK) { - jsfSelection = dlg.getResultFilePath(); - } - } - return jsfSelection; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PageSectionDescriptor.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PageSectionDescriptor.java deleted file mode 100644 index 3c5bdcaf0..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PageSectionDescriptor.java +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties; - -import java.util.List; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowNodeEditPart; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowPageImpl; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.section.PageSection; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.wst.common.ui.properties.internal.provisional.ISection; -import org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor; -import org.eclipse.wst.common.ui.properties.internal.provisional.ITypeMapper; - -/** - * @author jchoi - * @version - */ -public class PageSectionDescriptor implements ISectionDescriptor { - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getId() - */ - public String getId() { - return ITabbedPropertiesConstants.PAGE_SECTION; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getFilter() - */ - public ITypeMapper getFilter() { - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getInputTypes() - */ - public List getInputTypes() { - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getSectionClass() - */ - public ISection getSectionClass() { - return new PageSection(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getTargetTab() - */ - public String getTargetTab() { - return ITabbedPropertiesConstants.ATTRIBUTE_TAB_ID; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#appliesTo(org.eclipse.ui.IWorkbenchPart, - * org.eclipse.jface.viewers.ISelection) - */ - public boolean appliesTo(IWorkbenchPart part, ISelection selection) { - Object object = null; - if (selection instanceof StructuredSelection) { - StructuredSelection structuredSelection = (StructuredSelection) selection; - object = structuredSelection.getFirstElement(); - if (object instanceof PageflowNodeEditPart) { - Object model = ((PageflowNodeEditPart) object).getModel(); - if (model instanceof PageflowPageImpl) { - return true; - } - } - } - return false; - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getAfterSection() - */ - public String getAfterSection() { - return ITabbedPropertiesConstants.TOP_SECTION; - } - - public int getEnablesFor() { - // TODO Auto-generated method stub - return ENABLES_FOR_ANY; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PageflowElementPropertySource.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PageflowElementPropertySource.java deleted file mode 100644 index 25ee1779a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PageflowElementPropertySource.java +++ /dev/null @@ -1,476 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties; - -import java.util.Iterator; -import java.util.List; -import java.util.Vector; - -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EDataType; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.ICellEditorValidator; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowMessages; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.util.PageflowValidation; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor; -import org.eclipse.ui.views.properties.IPropertyDescriptor; -import org.eclipse.ui.views.properties.IPropertySource; -import org.eclipse.ui.views.properties.PropertyDescriptor; -import org.eclipse.ui.views.properties.TextPropertyDescriptor; - -/** - * This class is intended to be a generic property source for all the objects in - * the application's model. It currently only supports String and boolean types, - * and doesn't support reset or nested properties. It uses information in the - * EMF EAttribute and EDataType classes to get the id, display name, and type - * information. - * - * @author Xiao-guang Zhang - */ -public class PageflowElementPropertySource implements IPropertySource { - /** attribute name of "path" and "action", which have special property editor */ - private static final String PAGEFLOW_PATH = "path"; //$NON-NLS-1$ - - static final String PAGEFLOW_NAME = "name"; //$NON-NLS-1$ - - static final String PAGEFLOW_COMMENT = "comment"; //$NON-NLS-1$ - - private static final String PAGEFLOW_CONFIG_FILE = "configfile"; //$NON-NLS-1$ - - /** pageflow elememt */ - PageflowElement element; - - /** boolean value's label */ - private static final String P_VALUE_TRUE_LABEL = PageflowMessages.Pageflow_Label_True; - - private static final String P_VALUE_FALSE_LABEL = PageflowMessages.Pageflow_Label_False; - - /** Integer value for boolean type */ - private static final int P_VALUE_TRUE = 0; - - private static final int P_VALUE_FALSE = 1; - - static class BooleanLabelProvider extends LabelProvider { - public String getText(Object element) { - String[] values = new String[] { P_VALUE_TRUE_LABEL, - P_VALUE_FALSE_LABEL }; - return values[((Integer) element).intValue()]; - } - - public Image getImage(Object element) { - return EditorPlugin.getDefault().getImage( - "facesconfig/Pageflow_BooleanValue.gif"); //$NON-NLS-1$ - } - } - - static class PageflowLabelProvider extends LabelProvider { - - public Image getImage(Object element) { - if (element instanceof String) { - return EditorPlugin.getDefault().getImage( - "facesconfig/Pageflow_TextValue.gif");//$NON-NLS-1$ - } else if (element instanceof Integer) { - return EditorPlugin.getDefault().getImage( - "facesconfig/Pageflow_IntegralValue.gif");//$NON-NLS-1$ - } else { - return EditorPlugin.getDefault().getImage( - "facesconfig/Pageflow_GenericValue.gif");//$NON-NLS-1$ - } - } - } - - /** - * constructor - * - * @param element - - * pageflow element model. - */ - public PageflowElementPropertySource(PageflowElement element) { - this.element = element; - } - - /* - * (non-Javadoc) - * - * @see IPropertySource#getEditableValue() - */ - public Object getEditableValue() { - return element; - } - - /* - * (non-Javadoc) - * - * @see IPropertySource#getPropertyDescriptors() - */ - public IPropertyDescriptor[] getPropertyDescriptors() { - // property descriptors - List propertyDescriptors = new Vector(); - - // if (element instanceof PageflowLink) { - // return getLinkPropertyDescriptors(); - // } - - Iterator it; - EClass cls = element.eClass(); - - it = cls.getEAllAttributes().iterator(); - while (it.hasNext()) { - EAttribute attr = (EAttribute) it.next(); - if (attr.isID() - || attr.getFeatureID() == PageflowPackage.PAGEFLOW__REFERENCE_LINK) { - continue; - } - EDataType type = attr.getEAttributeType(); - if (type.getInstanceClass() == String.class) { - PropertyDescriptor propertyDescriptor; - if (attr.getName().equalsIgnoreCase(PAGEFLOW_PATH)) { - propertyDescriptor = getPagePathPropertyDescriptor(attr); - } else if (attr.getName() - .equalsIgnoreCase(PAGEFLOW_CONFIG_FILE)) { - propertyDescriptor = null; - } else { - propertyDescriptor = new TextPropertyDescriptor(Integer - .toString(attr.getFeatureID()), getString(attr - .getName())); - } - if (propertyDescriptor != null) { - propertyDescriptor - .setLabelProvider(new PageflowLabelProvider()); - propertyDescriptors.add(propertyDescriptor); - } - - } else if (type.getInstanceClass() == boolean.class) { - PropertyDescriptor propertyDescriptor; - propertyDescriptor = getBooleanTypePropertyDescriptor(attr); - propertyDescriptor.setLabelProvider(new BooleanLabelProvider()); - propertyDescriptors.add(propertyDescriptor); - } - } - - return (IPropertyDescriptor[]) propertyDescriptors - .toArray(new IPropertyDescriptor[] {}); - } - - /** - * @return - */ - // TODO: method not used; dead? -// private IPropertyDescriptor[] getLinkPropertyDescriptors() { -// // property descriptors -// List propertyDescriptors = new Vector(); -// -// Iterator it; -// EClass cls = element.eClass(); -// -// it = cls.getEAllAttributes().iterator(); -// while (it.hasNext()) { -// EAttribute attr = (EAttribute) it.next(); -// if (attr.isID() -// || attr.getName().equalsIgnoreCase(PAGEFLOW_NAME) -// || attr.getName().equalsIgnoreCase(PAGEFLOW_COMMENT) -// || attr.getFeatureID() == PageflowPackage.PAGEFLOW__REFERENCE_LINK) { -// continue; -// } -// -// EDataType type = attr.getEAttributeType(); -// if (type.getInstanceClass() == String.class) { -// PropertyDescriptor propertyDescriptor; -// -// propertyDescriptor = new TextPropertyDescriptor(Integer -// .toString(attr.getFeatureID()), getString(attr -// .getName())); -// -// if (propertyDescriptor != null) { -// propertyDescriptor -// .setLabelProvider(new PageflowLabelProvider()); -// propertyDescriptors.add(propertyDescriptor); -// } -// -// } else if (type.getInstanceClass() == boolean.class) { -// PropertyDescriptor propertyDescriptor; -// propertyDescriptor = getBooleanTypePropertyDescriptor(attr); -// propertyDescriptor.setLabelProvider(new BooleanLabelProvider()); -// propertyDescriptors.add(propertyDescriptor); -// } -// } -// -// return (IPropertyDescriptor[]) propertyDescriptors -// .toArray(new IPropertyDescriptor[] {}); -// } - - /** - * get the property descriptor for the attribute "path" of page component - * - * @param attr - - * EAttribute - * @return - */ - private PropertyDescriptor getPagePathPropertyDescriptor(EAttribute attr) { - PropertyDescriptor propertyDescriptor = new PropertyDescriptor(Integer - .toString(attr.getFeatureID()), getString(attr.getName())) { - public CellEditor createPropertyEditor(Composite parent) { - CellEditor editor = new PagePathDialogCellEditor(parent, - (PageflowPage) element); - if (getValidator() != null) { - editor.setValidator(getValidator()); - } - return editor; - } - - /** - * Returns the input validator for editing the property. - * - * @return the validator used to verify correct values for this - * property, or <code>null</code> - */ - protected ICellEditorValidator getValidator() { - return new ICellEditorValidator() { - public String isValid(Object value) { - if (((PageflowPage) element).getPath() != null - && value != null - && !((PageflowPage) element).getPath() - .equalsIgnoreCase((String) value)) { - if (PageflowValidation.getInstance().isExistedPage( - ((PageflowPage) element).getPageflow(), - (String) value)) { - // Pageflow.PageflowEditor.Alert.DNDResourceTitle - // = Pageflow Creation Error - // Pageflow.PageflowEditor.Alert.ExistingPage = - // The web page {0} is already existed in - // current PageFlow. - EditorPlugin - .getAlerts() - .error( - "Pageflow.PageflowEditor.Alert.DNDResourceTitle", - "Pageflow.PageflowEditor.Alert.ExistingPage", - value); - - return EditorPlugin - .getResourceString("Pageflow.PageflowEditor.Alert.ExistingPage"); - } - } - return null; - } - - }; - } - - }; - return propertyDescriptor; - } - - /** - * get the property descriptor for the attribute "action" of Action - * component - * - * @param attr - - * EAttribute - * @return - */ - // TODO: method not used; dead? -// private PropertyDescriptor getActionPropertyDescriptor(EAttribute attr) { -// PropertyDescriptor propertyDescriptor = new PropertyDescriptor(Integer -// .toString(attr.getFeatureID()), getString(attr.getName())) { -// public CellEditor createPropertyEditor(Composite parent) { -// CellEditor editor = new ActionDialogCellEditor(parent); -// if (getValidator() != null) { -// editor.setValidator(getValidator()); -// } -// return editor; -// } -// -// /** -// * Returns the input validator for editing the property. -// * -// * @return the validator used to verify correct values for this -// * property, or <code>null</code> -// */ -// protected ICellEditorValidator getValidator() { -// return new ICellEditorValidator() { -// public String isValid(Object value) { -// -// return null; -// } -// -// }; -// } -// }; -// return propertyDescriptor; -// } - - /** - * get the property descriptor for the attribute "outcome" of Link component - * - * @param attr - - * EAttribute - * @return - */ - // TODO: method not used; dead? -// private PropertyDescriptor getActionOutcomePropertyDescriptor( -// EAttribute attr) { -// PropertyDescriptor propertyDescriptor = new PropertyDescriptor(Integer -// .toString(attr.getFeatureID()), getString(attr.getName())) { -// public CellEditor createPropertyEditor(Composite parent) { -// CellEditor editor = new ActionOutcomeDialogCellEditor(parent, -// element); -// if (getValidator() != null) { -// editor.setValidator(getValidator()); -// } -// return editor; -// } -// }; -// return propertyDescriptor; -// } - - /** - * get property descriptor for the attribute with the boolean type - * - * @param attr - - * EAttribute - * @return - */ - PropertyDescriptor getBooleanTypePropertyDescriptor(EAttribute attr) { - PropertyDescriptor propertyDescriptor; - propertyDescriptor = new ComboBoxPropertyDescriptor(Integer - .toString(attr.getFeatureID()), getString(attr.getName()), - new String[] { P_VALUE_TRUE_LABEL, P_VALUE_FALSE_LABEL }); - return propertyDescriptor; - } - - /** - * Get a translated string from the resource locator. - */ - protected String getString(String key) { - if ("comment".equals(key)) { - return PageflowMessages.Pageflow_Model_Attributes_comment; - } - - if ("name".equals(key)) { - return PageflowMessages.Pageflow_Model_Attributes_name; - } - - if ("largeicon".equals(key)) { - return PageflowMessages.Pageflow_Model_Attributes_largeicon; - } - - if ("smallicon".equals(key)) { - return PageflowMessages.Pageflow_Model_Attributes_smallicon; - } - - if ("source".equals(key)) { - return PageflowMessages.Pageflow_Model_Attributes_source; - } - - if ("target".equals(key)) { - return PageflowMessages.Pageflow_Model_Attributes_target; - } - - if ("fromaction".equals(key)) { - return PageflowMessages.Pageflow_Model_Attributes_fromaction; - } - - if ("path".equals(key)) { - return PageflowMessages.Pageflow_Model_Attributes_path; - } - if ("begin".equals(key)) { - return PageflowMessages.Pageflow_Model_Attributes_begin; - } - if ("end".equals(key)) { - return PageflowMessages.Pageflow_Model_Attributes_end; - } - if ("configfile".equals(key)) { - return PageflowMessages.Pageflow_Model_Attributes_configfile; - } - if ("outcome".equals(key)) { - return PageflowMessages.Pageflow_Model_Attributes_outcome; - } - if ("redirect".equals(key)) { - return PageflowMessages.Pageflow_Model_Attributes_redirect; - } - - return ""; - } - - /* - * (non-Javadoc) - * - * @see IPropertySource#getPropertyValue(Object) - */ - public Object getPropertyValue(Object id) { - EStructuralFeature feature = element.eClass().getEStructuralFeature( - Integer.parseInt((String) id)); - - Object result = element.eGet(feature); - - if (result instanceof Boolean) { - if (result == Boolean.TRUE) { - result = new Integer(P_VALUE_TRUE); - } else { - result = new Integer(P_VALUE_FALSE); - } - } - - return result != null ? result : ""; - } - - /* - * (non-Javadoc) - * - * @see IPropertySource#isPropertySet(Object) - */ - public boolean isPropertySet(Object id) { - return false; - } - - /* - * (non-Javadoc) - * - * @see IPropertySouce#resetPropertyValue(Object) - */ - public void resetPropertyValue(Object id) { - // do nothing - } - - /* - * (non-Javadoc) - * - * @see IPropertySource#setPropertyValue(Object, Object) - */ - public void setPropertyValue(Object id, Object value) { - EStructuralFeature feature = element.eClass().getEStructuralFeature( - Integer.parseInt((String) id)); - - Object result = element.eGet(feature); - // if the attribute is boolean type, the value should be changed from - // string "true" or "false" - // to Boolean.TRUE or Boolean.FALSE - if (result instanceof Boolean) { - if (value.equals(new Integer(P_VALUE_TRUE))) { - value = Boolean.TRUE; - } else { - value = Boolean.FALSE; - } - } - element.eSet(feature, value); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PageflowLinkPropertySource.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PageflowLinkPropertySource.java deleted file mode 100644 index 8fdeef71f..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PageflowLinkPropertySource.java +++ /dev/null @@ -1,186 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties; - -import java.util.Iterator; -import java.util.List; -import java.util.Vector; - -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EDataType; -import org.eclipse.emf.ecore.EReference; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.ICellEditorValidator; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.util.PageflowValidation; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.views.properties.IPropertyDescriptor; -import org.eclipse.ui.views.properties.PropertyDescriptor; -import org.eclipse.ui.views.properties.TextPropertyDescriptor; - -/** - * The property source for Pageflow Link. - * - * @author hmeng - */ - -public class PageflowLinkPropertySource extends PageflowElementPropertySource { - - public PageflowLinkPropertySource(PageflowElement element) { - super(element); - // TODO Auto-generated constructor stub - } - - public Object getPropertyValue(Object id) { - Object result = super.getPropertyValue(id); - if (Integer.parseInt((String) id) == PageflowPackage.PF_LINK__SOURCE - || Integer.parseInt((String) id) == PageflowPackage.PF_LINK__TARGET) { - result = ((PageflowPage) result).getPath(); - } - return result; - } - - public void setPropertyValue(Object id, Object value) { - if (Integer.parseInt((String) id) == PageflowPackage.PF_LINK__SOURCE) { - ((PageflowLink) element).setSourcePath((String) value); - - } else if (Integer.parseInt((String) id) == PageflowPackage.PF_LINK__TARGET) { - ((PageflowLink) element).setTargetPath((String) value); - } else { - super.setPropertyValue(id, value); - } - } - - public IPropertyDescriptor[] getPropertyDescriptors() { - // property descriptors - List propertyDescriptors = new Vector(); - - Iterator it; - EClass cls = element.eClass(); - - it = cls.getEAllAttributes().iterator(); - while (it.hasNext()) { - EAttribute attr = (EAttribute) it.next(); - if (attr.isID() - || attr.getName().equalsIgnoreCase(PAGEFLOW_NAME) - || attr.getName().equalsIgnoreCase(PAGEFLOW_COMMENT) - || attr.getFeatureID() == PageflowPackage.PAGEFLOW__REFERENCE_LINK) { - continue; - } - - EDataType type = attr.getEAttributeType(); - if (type.getInstanceClass() == String.class) { - PropertyDescriptor propertyDescriptor; - - propertyDescriptor = new TextPropertyDescriptor(Integer - .toString(attr.getFeatureID()), - getString(attr.getName())); - - if (propertyDescriptor != null) { - propertyDescriptor - .setLabelProvider(new PageflowLabelProvider()); - propertyDescriptors.add(propertyDescriptor); - } - - } else if (type.getInstanceClass() == boolean.class) { - PropertyDescriptor propertyDescriptor; - propertyDescriptor = getBooleanTypePropertyDescriptor(attr); - propertyDescriptor.setLabelProvider(new BooleanLabelProvider()); - propertyDescriptors.add(propertyDescriptor); - } - } - it = cls.getEReferences().iterator(); - while (it.hasNext()) { - EReference attr = (EReference) it.next(); - if (attr.getFeatureID() == PageflowPackage.PF_LINK__SOURCE - || attr.getFeatureID() == PageflowPackage.PF_LINK__TARGET) { - - PropertyDescriptor propertyDescriptor; - - propertyDescriptor = getExistingPagePathPropertyDescriptor(attr); - - if (propertyDescriptor != null) { - propertyDescriptor - .setLabelProvider(new PageflowLabelProvider()); - propertyDescriptors.add(propertyDescriptor); - } - } - } - - return (IPropertyDescriptor[]) propertyDescriptors - .toArray(new IPropertyDescriptor[] {}); - } - - /** - * The link's ends can be modified to another page existing in current pageflow. - * @param attr - * @return - */ - private PropertyDescriptor getExistingPagePathPropertyDescriptor( - EReference attr) { - PropertyDescriptor propertyDescriptor = new PropertyDescriptor(Integer - .toString(attr.getFeatureID()), getString(attr.getName())) { - public CellEditor createPropertyEditor(Composite parent) { - CellEditor editor = new ExistingPagePathDialogCellEditor( - parent, (Pageflow) element.eContainer()); - if (getValidator() != null) { - editor.setValidator(getValidator()); - } - return editor; - } - - /** - * Returns the input validator for editing the property. - * - * @return the validator used to verify correct values for this - * property, or <code>null</code> - */ - protected ICellEditorValidator getValidator() { - return new ICellEditorValidator() { - public String isValid(Object value) { - if (value != null) { - if (!PageflowValidation.getInstance() - .isExistedPage( - ((Pageflow) element.eContainer()), - (String) value)) { - // Pageflow.PageflowEditor.Alert.DNDResourceTitle - // = Pageflow Creation Error - // Pageflow.PageflowEditor.Alert.ExistingPage = - // The web page {0} is already existed in - // current PageFlow. - EditorPlugin.getAlerts().info("Note", - "Please select an existing page"); - // "Pageflow.PageflowEditor.Alert.DNDResourceTitle", - // "Pageflow.PageflowEditor.Alert.ExistingPage", - // (String) value); - - return EditorPlugin - .getResourceString("Pageflow.PageflowEditor.Alert.ExistingPage"); - } - } - return null; - } - - }; - } - - }; - return propertyDescriptor; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PageflowSectionDescriptorProvider.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PageflowSectionDescriptorProvider.java deleted file mode 100644 index f795feef2..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PageflowSectionDescriptorProvider.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties; - -import org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor; -import org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptorProvider; - -/** - * this class defines all section descriptors for pageflow. Similar with - * PropertyDescriptors, this class defines all sections used by pageflow through - * SectionDescriptor. - * - */ -public class PageflowSectionDescriptorProvider implements - ISectionDescriptorProvider { - public PageflowSectionDescriptorProvider() { - super(); - } - - /* - * (non-Javadoc) - * - * @see ISectionDescriptorProvider#getSectionDescriptors() - */ - public ISectionDescriptor[] getSectionDescriptors() { - ISectionDescriptor[] descriptors = new ISectionDescriptor[] { - new LinkSectionDescriptor(), new PageSectionDescriptor(), - new EditorSectionDescriptor(), - new GeneralViewSectionDescriptor() }; - return descriptors; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PageflowSectionLabelProvider.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PageflowSectionLabelProvider.java deleted file mode 100644 index 28f5eb13a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PageflowSectionLabelProvider.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties; - -import org.eclipse.gef.editparts.AbstractEditPart; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowMessages; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowElementEditPart; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowElementTreeEditPart; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowLinkEditPart; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage; -import org.eclipse.swt.graphics.Image; - -/** - * This class defines label provider for the property view's title. Tabbed - * property view has a common area as a Title. Different decription and image - * can be shown according to Different selection. - * - */ -public class PageflowSectionLabelProvider extends LabelProvider { - - public PageflowSectionLabelProvider() { - super(); - } - - /* - * (non-Javadoc) - * - * @see getImage(java.lang.Object) - */ - public Image getImage(Object object) { - Image result = EditorPlugin.getDefault().getImage( - "facesconfig/FacesConfig_Pageflow16.gif"); - - return result; - } - - /* - * (non-Javadoc) - * - * @see getText(java.lang.Object) - */ - public String getText(Object object) { - String result = null; - if (object instanceof StructuredSelection) { - StructuredSelection structuredSelection = (StructuredSelection) object; - Object pageflow = structuredSelection.getFirstElement(); - if (pageflow instanceof PageflowElementEditPart - || pageflow instanceof PageflowLinkEditPart - || pageflow instanceof PageflowElementTreeEditPart) { - - if (((PageflowElement) ((AbstractEditPart) pageflow).getModel()) - .eClass() == PageflowPackage.eINSTANCE.getPageflow()) { - result = PageflowMessages.Pageflow_Model_Items_Pageflow; - } else if (((PageflowElement) ((AbstractEditPart) pageflow) - .getModel()).eClass() == PageflowPackage.eINSTANCE - .getPFPage()) { - result = PageflowMessages.Pageflow_Model_Items_PFPage; - } else if (((PageflowElement) ((AbstractEditPart) pageflow) - .getModel()).eClass() == PageflowPackage.eINSTANCE - .getPFLink()) { - result = PageflowMessages.Pageflow_Model_Items_PFLink; - } - } - } - return result; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ProjectWebPageSelectionDialog.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ProjectWebPageSelectionDialog.java deleted file mode 100644 index 45a7b7574..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/ProjectWebPageSelectionDialog.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jst.jsf.common.ui.internal.dialogs.CommonResourceDialog; -import org.eclipse.swt.widgets.Shell; - -/** - * @author hmeng - */ - -public class ProjectWebPageSelectionDialog extends CommonResourceDialog { - - public ProjectWebPageSelectionDialog(Shell parentShell, IProject project, - int style) { - super(parentShell, project, style); - init(); - } - - public ProjectWebPageSelectionDialog(Shell parentShell, IProject project) { - super(parentShell, project); - init(); - } - - public ProjectWebPageSelectionDialog(Shell parentShell, IFolder folder, - int style) { - super(parentShell, folder, style); - init(); - } - - private void init() { - setResourceDescription("Web page"); - setSuffixs(new String[] { "jsp", "jspx", "jsf", "html", "htm" }); - } - - public String getResultFilePath() { - String result = ""; - IFile selectedFile = (IFile) getResult()[0]; - IPath path = selectedFile.getProjectRelativePath(); - path = path.removeFirstSegments(1); - result = "/" + path.toString(); - return result; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PropertyMessages.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PropertyMessages.java deleted file mode 100644 index e803844ff..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PropertyMessages.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties; - -import org.eclipse.osgi.util.NLS; - -public final class PropertyMessages extends NLS { - - private static final String BUNDLE_NAME = "org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.PropertyMessages"; - - private PropertyMessages() { - // Do not instantiate - } - - static { - NLS.initializeMessages(BUNDLE_NAME, PropertyMessages.class); - } - - public static String property_displayName; - - public static String property_description; - - public static String property_configFile; - - public static String property_largeIcon; - - public static String property_smallIcon; - - public static String property_fromAction; - - public static String property_fromView; - - public static String property_fromOutcome; - - public static String property_redirect; - - public static String property_browseButton; - - public static String property_Command_SetValue; - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PropertyMessages.properties b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PropertyMessages.properties deleted file mode 100644 index b2a7b4ce1..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/PropertyMessages.properties +++ /dev/null @@ -1,22 +0,0 @@ -############################################################################### -# Copyright (c) 2001, 2006 Oracle Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Oracle Corporation - initial API and implementation -############################################################################### -property_displayName=Display Name: -property_description=Description: -property_configFile=Faces-config file: -property_largeIcon=Large Icon: -property_smallIcon=Small Icon: -property_fromAction=From Action: -property_fromView=Page Path: -property_fromOutcome=From Outcome: -property_redirect=Redirect: -property_browseButton=... - -property_Command_SetValue=Set {0} Property diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/AbstractEditPartGroup.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/AbstractEditPartGroup.java deleted file mode 100644 index a46eb1ce9..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/AbstractEditPartGroup.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.section; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogFieldGroup; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.StringDialogField; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.PropertyMessages; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * @author jchoi - * @version - */ -public abstract class AbstractEditPartGroup extends DialogFieldGroup { - - private StringDialogField descField; - - private StringDialogField displayNameField; - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogFieldGroup#initialize() - */ - public void initialize() { - displayNameField = new StringDialogField(); - displayNameField.setLabelText(PropertyMessages.property_displayName); - displayNameField - .setDialogFieldChangeListener(getDefaultChangeListener()); - descField = new StringDialogField(); - - descField.setLabelText(PropertyMessages.property_description); - descField.setDialogFieldChangeListener(getDefaultChangeListener()); - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogFieldGroup#layoutDialogFields(org.eclipse.ui.forms.widgets.FormToolkit, - * org.eclipse.swt.widgets.Composite) - */ - public void layoutDialogFields(FormToolkit toolkit, Composite parent, - int col) { - displayNameField.doFillIntoGrid(toolkit, parent, col); - descField.doFillIntoGrid(toolkit, parent, col); - - } - - protected void refreshData(PageflowElement elem) { - descField.setTextWithoutUpdate(elem.getComment()); - displayNameField.setTextWithoutUpdate(elem.getName()); - } - - public StringDialogField getDescField() { - return descField; - } - - public StringDialogField getDisplayNameField() { - return displayNameField; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogFieldGroup#initialize() - */ - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogFieldGroup#validateDialogFields() - */ - public IStatus[] validateDialogFields() { - - return null; - } - - protected String assertString(String value) { - return value == null ? "" : value; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/AbstractEditPartSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/AbstractEditPartSection.java deleted file mode 100644 index 37d902d6c..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/AbstractEditPartSection.java +++ /dev/null @@ -1,238 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.section; - -import java.util.EventObject; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.commands.CommandStack; -import org.eclipse.gef.commands.CommandStackListener; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.IDialogFieldChangeListener; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.views.properties.IPropertySource; -import org.eclipse.wst.common.ui.properties.internal.provisional.AbstractPropertySection; - -/** - * This is base section, which support GEF command stack to redo/undo setting - * properties. - * - * @author jchoi, Xiao-guang Zhang - */ -public abstract class AbstractEditPartSection extends AbstractPropertySection { - - IDialogFieldChangeListener changeListener = new IDialogFieldChangeListener() { - public void dialogFieldChanged(DialogField field) { - validate(); - } - }; - - /** property source of edit part */ - private IPropertySource propertySource; - - /** EditPart instance */ - private EditPart editPart; - - /** map for property registry to store a map between the property id and name */ - private Map propertyRegistry; - - /** GEF command stack */ - private CommandStack commandStack; - - /** command stack listener to refresh the section */ - private CommandStackListener commandStackListener; - - /** - * - */ - public AbstractEditPartSection() { - super(); - } - - /** - * refresh the whole section - * - */ - public void refreshData() { - super.refresh(); - } - - /** - * TODO: this method seems unused - */ - public abstract void validate(); - - /** - * dispose the command stack listener - */ - public void dispose() { - super.dispose(); - if (getCommandStack() != null) { - getCommandStack().removeCommandStackListener( - getCommandStackListener()); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#setInput(org.eclipse.ui.IWorkbenchPart, - * org.eclipse.jface.viewers.ISelection) - */ - public void setInput(IWorkbenchPart part, ISelection selection) { - if (part != null) { - if (part.getAdapter(CommandStack.class) != null) { - setCommandStack((CommandStack) part - .getAdapter(CommandStack.class)); - } - - if (selection instanceof StructuredSelection) { - StructuredSelection structuredSelection = (StructuredSelection) selection; - if (structuredSelection.getFirstElement() instanceof EditPart) { - editPart = (EditPart) structuredSelection.getFirstElement(); - } - - if (editPart != null - && ((IAdaptable) editPart) - .getAdapter(IPropertySource.class) != null) { - propertySource = (IPropertySource) ((IAdaptable) editPart) - .getAdapter(IPropertySource.class); - } - - } - } - - super.setInput(part, selection); - } - - /** - * get the commandstacklistener, if not existed, create a new one. - * - * @return - */ - private CommandStackListener getCommandStackListener() { - if (commandStackListener == null) { - commandStackListener = new CommandStackListener() { - public void commandStackChanged(EventObject e) { - refreshData(); - } - }; - } - return commandStackListener; - } - - /** - * set a <code>CommandStack</code> forthis section, and add a - * <code>CommandStackListener</code> for this commandstack - * - * @param stack - */ - public void setCommandStack(CommandStack stack) { - commandStack = stack; - stack.addCommandStackListener(getCommandStackListener()); - } - - /** - * get the <code>CommandStack</code> - * - * @return the command stack - */ - public CommandStack getCommandStack() { - return commandStack; - } - - /** - * get the property source registered for current editpart - * - * @return the property source - */ - public IPropertySource getPropertySource() { - return propertySource; - } - - /** - * get the property's EMF featureID based on property name. - * - * @param propertyName - * @return the feature id for propertyName - */ - protected Object getFeatureID(String propertyName) { - if (editPart != null && !(editPart.getModel() instanceof EObject)) { - return null; - } - - Object propertyID = getPropertyRegistry().get(propertyName); - if (propertyID == null) { - - EClass cls = ((EObject) editPart.getModel()).eClass(); - for (Iterator it = cls.getEAllAttributes().iterator(); it.hasNext();) { - EAttribute attr = (EAttribute) it.next(); - if (attr.getName().equalsIgnoreCase(propertyName)) { - propertyID = Integer.toString(attr.getFeatureID()); - getPropertyRegistry().put(propertyName, propertyID); - break; - } - } - } - return propertyID; - } - - /** - * @return the property registry - */ - protected Map getPropertyRegistry() { - if (propertyRegistry == null) { - propertyRegistry = new HashMap(); - } - return propertyRegistry; - } - - /** - * get the input edit part - * - * @return the input - */ - public Object getInput() { - return editPart; - } - - /** - * set the value of property - * - * @param propertyName - * @param propertyValue - */ - public void setValue(String propertyName, Object propertyValue) { - if (propertyName != null && propertyValue != null - && getPropertySource() != null) { - SetPropertyValueCommand setCommand = new SetPropertyValueCommand( - propertyName); - setCommand.setTarget(getPropertySource()); - setCommand.setPropertyId(getFeatureID(propertyName)); - setCommand.setPropertyValue(propertyValue); - if (getCommandStack() != null) { - getCommandStack().execute(setCommand); - } else { - setCommand.execute(); - } - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/EditorGroup.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/EditorGroup.java deleted file mode 100644 index 87d191e2a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/EditorGroup.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.section; - -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * @author jchoi - * @version - */ -public class EditorGroup extends AbstractEditPartGroup { - private Pageflow pageflow = null; - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogFieldGroup#initialize() - */ - public void initialize() { - super.initialize(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogFieldGroup#refreshData() - */ - public void refreshData() { - if (pageflow != null) { - super.refreshData(pageflow); - } - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogFieldGroup#layoutDialogFields(org.eclipse.ui.forms.widgets.FormToolkit, - * org.eclipse.swt.widgets.Composite) - */ - public void layoutDialogFields(FormToolkit toolkit, Composite parent) { - Composite top; - if (toolkit == null) { - top = new Composite(parent, SWT.NONE); - } else { - top = toolkit.createComposite(parent); - } - FillLayout fillLayout = new FillLayout(SWT.VERTICAL); - parent.setLayout(fillLayout); - - GridLayout layout = new GridLayout(); - layout.numColumns = 3; - top.setLayout(layout); - - Label separator = toolkit.createSeparator(top, SWT.HORIZONTAL); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 3; - separator.setLayoutData(data); - super.layoutDialogFields(toolkit, top, 3); - - } - - /** - * @param elem - */ - public void setPropertyProvider(Pageflow elem) { - pageflow = elem; - this.refreshData(); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/EditorSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/EditorSection.java deleted file mode 100644 index 5f1d9c446..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/EditorSection.java +++ /dev/null @@ -1,117 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.section; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.IDialogFieldApplyListener; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowEditPart; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowPackageImpl; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetPage; -import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory; - -/** - * Edit section for Pagflow (EditPart) - * - * @author jchoi, Xiao-guang Zhang - */ -public class EditorSection extends AbstractEditPartSection { - /** edit group */ - private EditorGroup group; - - /** the emf model for Pageflow */ - private Pageflow pageflow; - - /** - * - */ - public EditorSection() { - super(); - group = new EditorGroup(); - group.setDefaultChangeListener(changeListener); - group.initialize(); - - group.getDisplayNameField().setDialogFieldApplyListener( - new IDialogFieldApplyListener() { - public void dialogFieldApplied(DialogField field) { - EditorSection.this.setValue( - PageflowPackageImpl.eINSTANCE - .getPageflowElement_Name().getName(), - group.getDisplayNameField().getText()); - } - }); - - group.getDescField().setDialogFieldApplyListener( - new IDialogFieldApplyListener() { - public void dialogFieldApplied(DialogField field) { - EditorSection.this - .setValue( - PageflowPackageImpl.eINSTANCE - .getPageflowElement_Comment() - .getName(), group - .getDescField().getText()); - } - }); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#createControls(org.eclipse.swt.widgets.Composite, - * org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetPage) - */ - public void createControls(Composite parent, - TabbedPropertySheetPage aTabbedPropertySheetPage) { - super.createControls(parent, aTabbedPropertySheetPage); - TabbedPropertySheetWidgetFactory factory = aTabbedPropertySheetPage - .getWidgetFactory(); - Composite top = factory.createFlatFormComposite(parent); - - group.layoutDialogFields(factory, top); - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#setInput(org.eclipse.ui.IWorkbenchPart, - * org.eclipse.jface.viewers.ISelection) - */ - public void setInput(IWorkbenchPart part, ISelection selection) { - super.setInput(part, selection); - - if (getInput() != null && getInput() instanceof PageflowEditPart) { - Object model = ((PageflowEditPart) getInput()).getModel(); - if (model instanceof Pageflow) { - pageflow = (Pageflow) model; - refreshData(); - } - } - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.properties.sections.AbstractEditPartSection#refreshData() - */ - public void refreshData() { - super.refreshData(); - group.setPropertyProvider(pageflow); - } - - public void validate() { - // do nothing. - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/LinkGroup.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/LinkGroup.java deleted file mode 100644 index 55218d12b..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/LinkGroup.java +++ /dev/null @@ -1,201 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.section; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jface.window.Window; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.ComboDialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.IStringButtonAdapter; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.LayoutUtil; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.StringButtonDialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.StringDialogField; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.ActionOutcomeSelectionDialog; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.ITabbedPropertiesConstants; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.PropertyMessages; -import org.eclipse.jst.jsf.facesconfig.ui.util.WebrootUtil; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * @author jchoi - * @version - */ -public class LinkGroup extends AbstractEditPartGroup { - private StringButtonDialogField fromOutcomeField; - - private StringDialogField fromActionField; - - private ComboDialogField redirectField; - - private PageflowLink pfLink; - - /** Integer value for boolean type */ - private static final Integer P_VALUE_TRUE = new Integer(0); - - private static final Integer P_VALUE_FALSE = new Integer(1); - - private class StringButtonAdapter implements IStringButtonAdapter { - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.IStringButtonAdapter#changeControlPressed(org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogField) - */ - public void changeControlPressed(DialogField field) { - String outcome = ""; - String jspPage = ""; - Shell shell = field.getLabelControl(null, null).getShell(); - if (pfLink != null) { - outcome = pfLink.getOutcome(); - jspPage = WebrootUtil.getProjectPath(pfLink, - getPreviousJSPPath(pfLink)); - ActionOutcomeSelectionDialog actionDialog = new ActionOutcomeSelectionDialog( - shell, outcome, jspPage); - if (actionDialog.open() == Window.OK) { - outcome = actionDialog.getSelectedAction(); - fromOutcomeField.setText(outcome); - pfLink.setOutcome(outcome); - refreshData(); - } - } - } - - /** - * @param _element - * @return - */ - private String getPreviousJSPPath(PageflowElement element) { - String jspPath = null; - if (element instanceof PageflowLink) { - PageflowNode source = ((PageflowLink) element).getSource(); - if (source instanceof PageflowPage) { - jspPath = ((PageflowPage) source).getPath(); - } - } - return jspPath; - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogFieldGroup#initialize() - */ - public void initialize() { - fromOutcomeField = new StringButtonDialogField( - new StringButtonAdapter()); - fromOutcomeField.setLabelText(PropertyMessages.property_fromOutcome); - fromOutcomeField.setButtonLabel("..."); - fromOutcomeField - .setDialogFieldChangeListener(getDefaultChangeListener()); - fromActionField = new StringDialogField(); - fromActionField.setLabelText(PropertyMessages.property_fromAction); - fromActionField - .setDialogFieldChangeListener(getDefaultChangeListener()); - redirectField = new ComboDialogField(SWT.DROP_DOWN | SWT.READ_ONLY); - redirectField.setLabelText(PropertyMessages.property_redirect); - redirectField - .setDialogFieldChangeListener((getDefaultChangeListener())); - List redirectList; - redirectList = new ArrayList(); - redirectList.add(Boolean.TRUE.toString()); - redirectList.add(Boolean.FALSE.toString()); - redirectField.setItems((String[]) redirectList.toArray(new String[0])); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogFieldGroup#refreshData() - */ - public void refreshData() { - if (pfLink != null) { - fromOutcomeField.setTextWithoutUpdate(pfLink.getOutcome()); - fromActionField.setTextWithoutUpdate(pfLink.getFromaction()); - if (pfLink.isRedirect()) { - redirectField.setTextWithoutUpdate(Boolean.TRUE.toString()); - } else { - redirectField.setTextWithoutUpdate(Boolean.FALSE.toString()); - } - } - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogFieldGroup#layoutDialogFields(org.eclipse.ui.forms.widgets.FormToolkit, - * org.eclipse.swt.widgets.Composite) - */ - public void layoutDialogFields(FormToolkit toolkit, Composite parent) { - Composite top; - if (toolkit == null) { - top = new Composite(parent, SWT.NONE); - } else { - top = toolkit.createComposite(parent); - } - FillLayout fillLayout = new FillLayout(SWT.VERTICAL); - parent.setLayout(fillLayout); - - int numberOfColumns = 4; - GridLayout layout = new GridLayout(numberOfColumns, false); - top.setLayout(layout); - - fromActionField.doFillIntoGrid(toolkit, top, numberOfColumns); - fromOutcomeField.doFillIntoGrid(toolkit, top, numberOfColumns); - redirectField.doFillIntoGrid(toolkit, top, numberOfColumns); - - LayoutUtil.setHorizontalGrabbing(fromOutcomeField.getTextControl( - toolkit, top)); - GridData data = new GridData(); - data.widthHint = ITabbedPropertiesConstants.BROWSE_WIDTH; - data.heightHint = ITabbedPropertiesConstants.BROWSE_HEIGHT; - - fromOutcomeField.getChangeControl(toolkit, top).setLayoutData(data); - - } - - public void setPropertyProvider(PageflowLink elem) { - pfLink = elem; - this.refreshData(); - } - - public StringButtonDialogField getFromOutcomeField() { - return fromOutcomeField; - } - - public StringDialogField getFromActionField() { - return fromActionField; - } - - public ComboDialogField getRedirectField() { - return redirectField; - } - - public Integer getRedirectValue() { - if (redirectField.getText().equalsIgnoreCase(Boolean.TRUE.toString())) { - return LinkGroup.P_VALUE_TRUE; - } - return LinkGroup.P_VALUE_FALSE; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/LinkSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/LinkSection.java deleted file mode 100644 index e223a7475..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/LinkSection.java +++ /dev/null @@ -1,126 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.section; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.IDialogFieldApplyListener; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowLinkEditPart; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowPackageImpl; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.util.PageflowValidation; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetPage; -import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory; - -/** - * Edit section for Pagflow Link element (EditPart) - * - * @author jchoi - */ -public class LinkSection extends AbstractEditPartSection { - /** edit group */ - private LinkGroup group; - - /** the emf model for Pageflow link */ - private PageflowLink pfLink; - - /** - * - */ - public LinkSection() { - super(); - group = new LinkGroup(); - group.setDefaultChangeListener(changeListener); - group.initialize(); - - group.getFromOutcomeField().setDialogFieldApplyListener( - new IDialogFieldApplyListener() { - public void dialogFieldApplied(DialogField field) { - LinkSection.this.setValue(PageflowPackageImpl.eINSTANCE - .getPFLink_Outcome().getName(), group - .getFromOutcomeField().getText()); - } - }); - - group.getRedirectField().setDialogFieldApplyListener( - new IDialogFieldApplyListener() { - public void dialogFieldApplied(DialogField field) { - LinkSection.this.setValue(PageflowPackageImpl.eINSTANCE - .getPFLink_Redirect().getName(), group - .getRedirectValue()); - } - }); - group.getFromActionField().setDialogFieldApplyListener( - new IDialogFieldApplyListener() { - public void dialogFieldApplied(DialogField field) { - LinkSection.this.setValue(PageflowPackageImpl.eINSTANCE - .getPFLink_Fromaction().getName(), group - .getFromActionField().getText()); - } - }); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#createControls(org.eclipse.swt.widgets.Composite, - * org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetPage) - */ - public void createControls(Composite parent, - TabbedPropertySheetPage aTabbedPropertySheetPage) { - super.createControls(parent, aTabbedPropertySheetPage); - TabbedPropertySheetWidgetFactory factory = aTabbedPropertySheetPage - .getWidgetFactory(); - Composite top = factory.createFlatFormComposite(parent); - - group.layoutDialogFields(factory, top); - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#setInput(org.eclipse.ui.IWorkbenchPart, - * org.eclipse.jface.viewers.ISelection) - */ - public void setInput(IWorkbenchPart part, ISelection selection) { - super.setInput(part, selection); - - if (getInput() != null && getInput() instanceof PageflowLinkEditPart) { - Object model = ((PageflowLinkEditPart) getInput()).getModel(); - if (model instanceof PageflowLink) { - pfLink = (PageflowLink) model; - if (PageflowValidation.getInstance().isValidLinkForProperty( - pfLink)) { - refreshData(); - } - } - } - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.properties.sections.AbstractEditPartSection#refreshData() - */ - public void refreshData() { - super.refresh(); - group.setPropertyProvider(pfLink); - } - - public void validate() { - // do nothing - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/PageGroup.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/PageGroup.java deleted file mode 100644 index bcaba514d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/PageGroup.java +++ /dev/null @@ -1,155 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.section; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jface.window.Window; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.IStringButtonAdapter; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.LayoutUtil; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.StringButtonDialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.StringDialogField; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.ITabbedPropertiesConstants; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.ProjectWebPageSelectionDialog; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.PropertyMessages; -import org.eclipse.jst.jsf.facesconfig.ui.util.WebrootUtil; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * @author jchoi - * @version - */ -public class PageGroup extends AbstractEditPartGroup { - - private StringButtonDialogField fromViewField; - - private PageflowPage pfPage = null; - - private StringDialogField largeIconField; - - private StringDialogField smallIconField; - - class StringButtonAdapter implements IStringButtonAdapter { - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.IStringButtonAdapter#changeControlPressed(org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogField) - */ - public void changeControlPressed(DialogField field) { - IProject project = WebrootUtil.getProject(pfPage); - ProjectWebPageSelectionDialog dlg = new ProjectWebPageSelectionDialog( - field.getLabelControl(null, null).getShell(), project); - if (dlg.open() == Window.OK) { - fromViewField.setText(dlg.getResultFilePath()); - } - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogFieldGroup#initialize() - */ - public void initialize() { - fromViewField = new StringButtonDialogField(new StringButtonAdapter()); - fromViewField.setLabelText(PropertyMessages.property_fromView); - fromViewField.setButtonLabel("..."); - fromViewField.setDialogFieldChangeListener(getDefaultChangeListener()); - - largeIconField = new StringDialogField(); - largeIconField.setLabelText(PropertyMessages.property_largeIcon); - largeIconField - .setDialogFieldChangeListener((getDefaultChangeListener())); - smallIconField = new StringDialogField(); - smallIconField.setLabelText(PropertyMessages.property_smallIcon); - smallIconField - .setDialogFieldChangeListener((getDefaultChangeListener())); - super.initialize(); - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogFieldGroup#refreshData() - */ - public void refreshData() { - if (pfPage != null) { - fromViewField.setTextWithoutUpdate(assertString(pfPage.getPath())); - largeIconField.setTextWithoutUpdate(assertString(pfPage - .getLargeicon())); - smallIconField.setTextWithoutUpdate(assertString(pfPage - .getSmallicon())); - super.refreshData(pfPage); - - } - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogFieldGroup#layoutDialogFields(org.eclipse.ui.forms.widgets.FormToolkit, - * org.eclipse.swt.widgets.Composite) - */ - public void layoutDialogFields(FormToolkit toolkit, Composite parent) { - Composite top; - if (toolkit == null) { - top = new Composite(parent, SWT.NONE); - } else { - top = toolkit.createComposite(parent); - } - FillLayout fillLayout = new FillLayout(SWT.VERTICAL); - parent.setLayout(fillLayout); - - int numberOfColumns = 4; - GridLayout layout = new GridLayout(numberOfColumns, false); - top.setLayout(layout); - - fromViewField.doFillIntoGrid(toolkit, top, numberOfColumns); - LayoutUtil.setHorizontalGrabbing(fromViewField.getTextControl(toolkit, - top)); - largeIconField.doFillIntoGrid(toolkit, top, numberOfColumns); - smallIconField.doFillIntoGrid(toolkit, top, numberOfColumns); - super.layoutDialogFields(toolkit, top, 4); - - GridData data = new GridData(); - data.widthHint = ITabbedPropertiesConstants.BROWSE_WIDTH; - data.heightHint = ITabbedPropertiesConstants.BROWSE_HEIGHT; - - fromViewField.getChangeControl(toolkit, top).setLayoutData(data); - } - - public void setPropertyProvider(PageflowPage elem) { - pfPage = elem; - this.refreshData(); - } - - public StringButtonDialogField getFromViewField() { - return fromViewField; - } - - public StringDialogField getLargeIconField() { - return largeIconField; - } - - public StringDialogField getSmallIconField() { - return smallIconField; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/PageSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/PageSection.java deleted file mode 100644 index 65931743b..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/PageSection.java +++ /dev/null @@ -1,168 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.section; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.IDialogFieldApplyListener; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowNodeEditPart; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowPackageImpl; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.util.PageflowValidation; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetPage; -import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory; - -/** - * Edit section for Pagflow Page Element (EditPart) - * - * @author jchoi, Xiao-guang Zhang - */ -public class PageSection extends AbstractEditPartSection { - /** edit group */ - private PageGroup group; - - /** the emf model for Pageflow page */ - private PageflowPage pfPage = null; - - /** - * - */ - public PageSection() { - super(); - group = new PageGroup(); - group.setDefaultChangeListener(changeListener); - group.initialize(); - - group.getFromViewField().setDialogFieldApplyListener( - new IDialogFieldApplyListener() { - - public void dialogFieldApplied(DialogField field) { - if (pfPage != null) { - String jsfNew = group.getFromViewField().getText(); - if (jsfNew != null && jsfNew.length() > 0) { - if (PageflowValidation.getInstance() - .isExistedPage(pfPage.getPageflow(), - jsfNew)) { - // Pageflow.PageflowEditor.Alert.DNDResourceTitle - // = Pageflow Creation Error - // Pageflow.PageflowEditor.Alert.ExistingPage - // = The web page {0} is already existed in - // current PageFlow. - EditorPlugin - .getAlerts() - .error( - "Pageflow.PageflowEditor.Alert.DNDResourceTitle", - "Pageflow.PageflowEditor.Alert.ExistingPage", - jsfNew); - } else { - PageSection.this - .setValue( - PageflowPackageImpl.eINSTANCE - .getPFPage_Path() - .getName(), jsfNew); - } - } - } - } - }); - - group.getLargeIconField().setDialogFieldApplyListener( - new IDialogFieldApplyListener() { - - public void dialogFieldApplied(DialogField field) { - PageSection.this.setValue(PageflowPackageImpl.eINSTANCE - .getPFPage_Largeicon().getName(), group - .getLargeIconField().getText()); - } - }); - group.getSmallIconField().setDialogFieldApplyListener( - new IDialogFieldApplyListener() { - - public void dialogFieldApplied(DialogField field) { - PageSection.this.setValue(PageflowPackageImpl.eINSTANCE - .getPFPage_Smallicon().getName(), group - .getSmallIconField().getText()); - } - }); - - group.getDescField().setDialogFieldApplyListener( - new IDialogFieldApplyListener() { - - public void dialogFieldApplied(DialogField field) { - PageSection.this.setValue(PageflowPackageImpl.eINSTANCE - .getPageflowElement_Comment().getName(), group - .getDescField().getText()); - } - }); - - group.getDisplayNameField().setDialogFieldApplyListener( - new IDialogFieldApplyListener() { - - public void dialogFieldApplied(DialogField field) { - PageSection.this.setValue(PageflowPackageImpl.eINSTANCE - .getPageflowElement_Name().getName(), group - .getDisplayNameField().getText()); - } - }); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#createControls(org.eclipse.swt.widgets.Composite, - * org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetPage) - */ - public void createControls(Composite parent, - TabbedPropertySheetPage aTabbedPropertySheetPage) { - super.createControls(parent, aTabbedPropertySheetPage); - TabbedPropertySheetWidgetFactory factory = aTabbedPropertySheetPage - .getWidgetFactory(); - Composite top = factory.createFlatFormComposite(parent); - - group.layoutDialogFields(factory, top); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#setInput(org.eclipse.ui.IWorkbenchPart, - * org.eclipse.jface.viewers.ISelection) - */ - public void setInput(IWorkbenchPart part, ISelection selection) { - super.setInput(part, selection); - - if (getInput() != null && getInput() instanceof PageflowNodeEditPart) { - Object model = ((PageflowNodeEditPart) getInput()).getModel(); - if (model instanceof PageflowPage) { - pfPage = (PageflowPage) model; - refreshData(); - } - } - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.properties.sections.AbstractEditPartSection#refreshData() - */ - public void refreshData() { - super.refreshData(); - group.setPropertyProvider(pfPage); - } - - public void validate() { - // do nothing - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/SetPropertyValueCommand.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/SetPropertyValueCommand.java deleted file mode 100644 index 67df3ca41..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/properties/section/SetPropertyValueCommand.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.section; - -import java.text.MessageFormat; - -import org.eclipse.gef.commands.Command; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.properties.PropertyMessages; -import org.eclipse.ui.views.properties.IPropertySource; - -public class SetPropertyValueCommand extends Command { - - protected Object propertyValue; - - protected Object propertyID; - - protected Object undoValue; - - protected boolean resetOnUndo; - - protected IPropertySource target; - - public SetPropertyValueCommand() { - super(""); //$NON-NLS-1$ - } - - public SetPropertyValueCommand(String propLabel) { - super(MessageFormat.format( - PropertyMessages.property_Command_SetValue, - new Object[] { propLabel }).trim()); - } - - public boolean canExecute() { - return true; - } - - public void execute() { - boolean wasPropertySet = getTarget().isPropertySet(propertyID); - undoValue = getTarget().getPropertyValue(propertyID); - if (undoValue instanceof IPropertySource) { - undoValue = ((IPropertySource) undoValue).getEditableValue(); - } - if (propertyValue instanceof IPropertySource) { - propertyValue = ((IPropertySource) propertyValue) - .getEditableValue(); - } - getTarget().setPropertyValue(propertyID, propertyValue); - resetOnUndo = wasPropertySet != getTarget().isPropertySet(propertyID); - if (resetOnUndo) { - undoValue = null; - } - } - - public IPropertySource getTarget() { - return target; - } - - public void setTarget(IPropertySource aTarget) { - target = aTarget; - } - - public void redo() { - execute(); - } - - public void setPropertyId(Object pName) { - propertyID = pName; - } - - public void setPropertyValue(Object val) { - propertyValue = val; - } - - public void undo() { - if (resetOnUndo) { - getTarget().resetPropertyValue(propertyID); - } else { - getTarget().setPropertyValue(propertyID, undoValue); - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFSynchronizer.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFSynchronizer.java deleted file mode 100644 index 334b5b418..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFSynchronizer.java +++ /dev/null @@ -1,268 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.synchronization; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.Notifier; -import org.eclipse.emf.common.notify.impl.AdapterImpl; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.jst.jsf.common.ui.internal.logging.Logger; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.emf.FromViewIdType; -import org.eclipse.jst.jsf.facesconfig.emf.NavigationCaseType; -import org.eclipse.jst.jsf.facesconfig.emf.NavigationRuleType; -import org.eclipse.jst.jsf.facesconfig.emf.ToViewIdType; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage; - -/** - * The adapter that listens to modification of faces-config and updates pageflow - * as needed. - * - * @author hmeng - * - */ - -public class FC2PFSynchronizer extends AdapterImpl { - private final boolean DEBUG = false; - - FC2PFTransformer transformer; - - private static final Logger logger = EditorPlugin - .getLogger(FC2PFSynchronizer.class); - - public FC2PFSynchronizer(FC2PFTransformer transformer) { - this.transformer = transformer; - } - - public Notifier getTarget() { - // can't set target so return null - return null; - } - - public void setTarget(Notifier newTarget) { - // do nothing - } - - public boolean isAdapterForType(Object type) { - return type == FC2PFSynchronizer.class; - } - - public void notifyChanged(Notification notification) { - if (!isProcessorFor(notification)) { - return; - } - transformer.setInEvent(true); - try { - int type = notification.getEventType(); - switch (type) { - case Notification.ADD: { - processAdd(notification); - notifyPageflow(notification); - break; - } - case Notification.SET: { - processSet(notification); - notifyPageflow(notification); - break; - } - case Notification.REMOVE: - processRemove(notification); - notifyPageflow(notification); - break; - } - } catch (Exception e) { - logger.error(e); - } finally { - if (notification.getEventType() != Notification.REMOVING_ADAPTER) { - transformer.refreshFCAdapter((EObject) notification - .getNotifier()); - transformer.refreshPFAdapter(transformer.getPageflow()); - } - transformer.setInEvent(false); - } - } - - private boolean isProcessorFor(Notification notification) { - boolean result = false; - if (transformer.isListenToNotify() - && (notification.getNotifier() instanceof EObject)) { - if (notification.getNotifier() == transformer.getFacesConfig()) { - // For faces-config, only navigation rule's change is awared. - if (notification.getFeature() == FacesConfigPackage.eINSTANCE - .getFacesConfigType_NavigationRule()) { - result = true; - } - } else { - result = true; - } - } - return result; - } - - private void processAdd(Notification notification) { - Object feature = notification.getFeature(); - if (feature == FacesConfigPackage.eINSTANCE - .getNavigationRuleType_NavigationCase()) { - if (DEBUG) - System.out.println("New navigation case"); - NavigationCaseType newCase = (NavigationCaseType) notification - .getNewValue(); - transformer.updatePageflowElements(transformer.getPageflow(), - newCase); - } else if (feature == FacesConfigPackage.eINSTANCE - .getFacesConfigType_NavigationRule()) { - NavigationRuleType newRule = (NavigationRuleType) notification - .getNewValue(); - if (newRule.getNavigationCase().size() > 0) { - for (int i = 0; i < newRule.getNavigationCase().size(); i++) { - transformer.updatePageflowElements(transformer - .getPageflow(), (NavigationCaseType) newRule - .getNavigationCase().get(i)); - } - } - if (DEBUG) - System.out.println("New navigation rule"); - } else if (DEBUG) - System.out.println("Something is added"); - } - - /** - * Notify pageflow the changes. - * - * @param notification - */ - private void notifyPageflow(Notification notification) { - Assert.isTrue(notification.getNotifier() instanceof InternalEObject); - transformer.getPageflow().notifyModelChanged( - new ENotificationImpl((InternalEObject) notification - .getNotifier(), Notification.SET, - PageflowPackage.PAGEFLOW, null, null)); - } - - /** - * Deal with the case when some element is removed. - * - * @param notification - */ - private void processRemove(Notification notification) { - if (notification.getFeature() == FacesConfigPackage.eINSTANCE - .getNavigationRuleType_NavigationCase()) { - if (notification.getOldValue() instanceof NavigationCaseType) { - NavigationCaseType caseType = (NavigationCaseType) notification - .getOldValue(); - transformer.removeLink(caseType); - } - if (DEBUG) - System.out.println("Navigation case"); - } else if (notification.getFeature() == FacesConfigPackage.eINSTANCE - .getNavigationCaseType()) { - if (notification.getOldValue() instanceof NavigationRuleType) { - NavigationRuleType rule = (NavigationRuleType) notification - .getOldValue(); - for (int i = 0; i < rule.getNavigationCase().size(); i++) { - NavigationCaseType caseType = (NavigationCaseType) rule - .getNavigationCase().get(i); - transformer.refreshLink(caseType); - } - } - if (DEBUG) - System.out.println("navigation rule"); - } else if (notification.getFeature() == FacesConfigPackage.eINSTANCE - .getFacesConfigType_NavigationRule()) { - if (notification.getOldValue() instanceof NavigationRuleType) { - NavigationRuleType rule = (NavigationRuleType) notification - .getOldValue(); - for (int i = 0; i < rule.getNavigationCase().size(); i++) { - NavigationCaseType caseType = (NavigationCaseType) rule - .getNavigationCase().get(i); - transformer.refreshLink(caseType); - } - } - } - if (DEBUG) - System.out.println("Something is removed"); - } - - /** - * Deal with property change. - * - * @param notification - */ - private void processSet(Notification notification) { - Object feature = notification.getFeature(); - if (feature == FacesConfigPackage.eINSTANCE - .getFromViewIdType_TextContent() - || feature == FacesConfigPackage.eINSTANCE - .getNavigationRuleType_FromViewId()) { - fromViewIdChanged(notification); - } else if (feature == FacesConfigPackage.eINSTANCE - .getToViewIdType_TextContent() - || feature == FacesConfigPackage.eINSTANCE - .getNavigationCaseType_ToViewId()) { - toViewIdChanged(notification); - } - if (DEBUG) - System.out.println("Something is set"); - } - - private void fromViewIdChanged(Notification notification) { - // remove - Object feature = notification.getFeature(); - if (feature == FacesConfigPackage.eINSTANCE - .getNavigationRuleType_FromViewId() - && notification.getNewValue() == null - && notification.getOldValue() instanceof FromViewIdType) { - NavigationRuleType rule = (NavigationRuleType) notification - .getNotifier(); - for (int i = 0; i < rule.getNavigationCase().size(); i++) { - NavigationCaseType caseType = (NavigationCaseType) rule - .getNavigationCase().get(i); - transformer.refreshLink(caseType); - } - } - // add or change - else if (feature == FacesConfigPackage.eINSTANCE - .getFromViewIdType_TextContent()) { - NavigationRuleType rule = (NavigationRuleType) ((EObject) notification - .getNotifier()).eContainer(); - for (int i = 0; i < rule.getNavigationCase().size(); i++) { - NavigationCaseType caseType = (NavigationCaseType) rule - .getNavigationCase().get(i); - transformer.refreshLink(caseType); - } - } - } - - private void toViewIdChanged(Notification notification) { - // remove - Object feature = notification.getFeature(); - if (feature == FacesConfigPackage.eINSTANCE - .getNavigationCaseType_ToViewId() - && notification.getNewValue() == null - && notification.getOldValue() instanceof ToViewIdType) { - NavigationCaseType caseType = (NavigationCaseType) notification - .getNotifier(); - transformer.refreshLink(caseType); - } - // add or change - else if (feature == FacesConfigPackage.eINSTANCE - .getToViewIdType_TextContent()) { - NavigationCaseType caseType = (NavigationCaseType) ((EObject) notification - .getNotifier()).eContainer(); - transformer.refreshLink(caseType); - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer.java deleted file mode 100644 index 6814b90da..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/FC2PFTransformer.java +++ /dev/null @@ -1,945 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.synchronization; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.Notifier; -import org.eclipse.emf.common.notify.impl.AdapterImpl; -import org.eclipse.emf.common.util.TreeIterator; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.jst.jsf.facesconfig.emf.DescriptionType; -import org.eclipse.jst.jsf.facesconfig.emf.DisplayNameType; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigType; -import org.eclipse.jst.jsf.facesconfig.emf.FromViewIdType; -import org.eclipse.jst.jsf.facesconfig.emf.IconType; -import org.eclipse.jst.jsf.facesconfig.emf.LargeIconType; -import org.eclipse.jst.jsf.facesconfig.emf.NavigationCaseType; -import org.eclipse.jst.jsf.facesconfig.emf.NavigationRuleType; -import org.eclipse.jst.jsf.facesconfig.emf.SmallIconType; -import org.eclipse.jst.jsf.facesconfig.emf.ToViewIdType; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowFactory; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageReferenceElement; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.ReferenceElement; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.util.PageflowModelManager; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.util.PageflowTransform; -import org.eclipse.jst.jsf.facesconfig.ui.util.WebrootUtil; - -/** - * Update and synchronize pageflow from faces-config or vice-versa. - * - * @author hmeng - * - */ - -public class FC2PFTransformer extends AdapterImpl { - - // For code debug. - private static final boolean DEBUG = false; - - public static final int MY_NOTIFICATION_TYPE = Notification.EVENT_TYPE_COUNT + 1; - - public static final int MY_NOTIFICATION_TYPE1 = MY_NOTIFICATION_TYPE + 1; - - /** - * The listener is active. - */ - private boolean listenToNotify; - - /** - * Avoid redundent event. - */ - private boolean isInEvent; - - boolean pageflowChanged = false; - - /** - * Perform operations batched. - */ - boolean needBatchOperations = false; - - /** - * Catches - */ - private Map mapPaths2PF = new HashMap(); - - private Map mapCases2Links = new HashMap(); - - /** - * The pageflow model. - */ - private Pageflow pageflow; - - /** - * The faces-config model. - */ - FacesConfigType facesConfig; - - public FC2PFTransformer() { - super(); - // TODO Auto-generated constructor stub - } - - public void setListenToNotify(boolean listenToNotify) { - this.listenToNotify = listenToNotify; - } - - private void postEMFChanged() { - startFCNotify(); - // Refresh all facesConfig? - facesConfig.eNotify(new ENotificationImpl( - (InternalEObject) facesConfig, Notification.REMOVE, - FacesConfigPackage.FACES_CONFIG_TYPE__NAVIGATION_RULE, null, - null)); - List rules; - rules = facesConfig.getNavigationRule(); - for (int i = 0; i < rules.size(); i++) { - ((NavigationRuleType) rules.get(i)).eNotify(new ENotificationImpl( - (InternalEObject) rules.get(i), Notification.REMOVE, - FacesConfigPackage.NAVIGATION_RULE_TYPE__NAVIGATION_CASE, - null, null)); - } - } - - /** - * Set notify adapters. - * - */ - private void startFCNotify() { - TreeIterator iterator = facesConfig.eAllContents(); - while (iterator.hasNext()) { - EObject object = (EObject) iterator.next(); - object.eSetDeliver(true); - } - facesConfig.eSetDeliver(true); - } - - /** - * Set not notify adapters - * - * @return - */ - private TreeIterator stopFCNotify() { - TreeIterator iterator = facesConfig.eAllContents(); - // Stop the listener - while (iterator.hasNext()) { - EObject object = (EObject) iterator.next(); - object.eSetDeliver(false); - } - facesConfig.eSetDeliver(false); - return iterator; - } - - /** - * For performance issue, we are going to update DOM only after the EMF - * modifications are done. - */ - boolean isNeedBatchOperations() { - return needBatchOperations; - } - - /** - * @param enable - */ - public void setNeedBatchOperations(boolean enable) { - this.needBatchOperations = enable; - if (!enable) { - isInEvent = true; - postEMFChanged(); - isInEvent = false; - } else { - stopFCNotify(); - } - } - - private void updateFacesRule(NavigationRuleType navigationRule, - PageflowPage pageSource) { - FacesConfigFactory factory = FacesConfigFactory.eINSTANCE; - if (pageSource.getComment() != null) { - DescriptionType description = factory.createDescriptionType(); - description.setTextContent(pageSource.getComment()); - navigationRule.getDescription().clear(); - navigationRule.getDescription().add(description); - } - // set the navigation rule's icon - if (pageSource.getLargeicon() != null - || pageSource.getSmallicon() != null) { - IconType icon = factory.createIconType(); - if (pageSource.getLargeicon() != null) { - LargeIconType largeicon = factory.createLargeIconType(); - largeicon.setTextContent(pageSource.getLargeicon()); - icon.setLargeIcon(largeicon); - } - - if (pageSource.getSmallicon() != null) { - SmallIconType smallicon = factory.createSmallIconType(); - smallicon.setTextContent(pageSource.getSmallicon()); - icon.setSmallIcon(smallicon); - } - navigationRule.getIcon().clear(); - navigationRule.getIcon().add(icon); - } - if (pageSource.getName() != null) { - DisplayNameType displayName = factory.createDisplayNameType(); - displayName.setTextContent(pageSource.getName()); - navigationRule.getDisplayName().clear(); - navigationRule.getDisplayName().add(displayName); - } - } - - /** - * TODO: If we cache the case's properties in a link, then we can restore - * them. - * - * @param navigationCase - * @param link - */ - // TODO: not used, dead? -// private void updateFacesCase(NavigationCaseType navigationCase, -// PageflowLink link) { -// FacesConfigFactory factory = FacesConfigFactory.eINSTANCE; -// if (link.getComment() != null) { -// DescriptionType description = factory.createDescriptionType(); -// description.setTextContent(link.getComment()); -// navigationCase.getDescription().clear(); -// navigationCase.getDescription().add(description); -// } -// // set the navigation rule's icon -// if (link.getLargeicon() != null || link.getSmallicon() != null) { -// IconType icon = factory.createIconType(); -// if (link.getLargeicon() != null) { -// LargeIconType largeicon = factory.createLargeIconType(); -// largeicon.setTextContent(link.getLargeicon()); -// icon.setLargeIcon(largeicon); -// } -// -// if (link.getSmallicon() != null) { -// SmallIconType smallicon = factory.createSmallIconType(); -// smallicon.setTextContent(link.getSmallicon()); -// icon.setSmallIcon(smallicon); -// } -// navigationCase.getIcon().clear(); -// navigationCase.getIcon().add(icon); -// } -// if (link.getFromaction() != null) { -// FromActionType fromAction = factory.createFromActionType(); -// fromAction.setTextContent(link.getFromaction()); -// navigationCase.setFromAction(fromAction); -// } -// if (link.getOutcome() != null) { -// FromOutcomeType fromOutcome = factory.createFromOutcomeType(); -// fromOutcome.setTextContent(link.getOutcome()); -// navigationCase.setFromOutcome(fromOutcome); -// } -// } - - private void createFacesCase(PageflowLink link, PageflowPage source, - PageflowPage target_) { - NavigationRuleType rule = FacesConfigFactory.eINSTANCE - .createNavigationRuleType(); - FromViewIdType from = FacesConfigFactory.eINSTANCE - .createFromViewIdType(); - from.setTextContent((source).getPath()); - rule.setFromViewId(from); - NavigationCaseType navCase = FacesConfigFactory.eINSTANCE - .createNavigationCaseType(); - ToViewIdType toView = FacesConfigFactory.eINSTANCE.createToViewIdType(); - toView.setTextContent((target_).getPath()); - navCase.setToViewId(toView); - rule.getNavigationCase().add(navCase); - facesConfig.getNavigationRule().add(rule); - updateFacesRule(rule, source); - source.getFCElements().add(from); - target_.getFCElements().add(toView); - link.getFCElements().add(navCase); - mapCases2Links.put(navCase, link); - } - - private void removePageflowPage(PageflowPage source) { - Assert.isTrue(source.getOutlinks().size() == 0 - && source.getInlinks().size() == 0); - pageflow.getNodes().remove(source); - } - - void removeCase(NavigationCaseType navCase) { - NavigationRuleType rule = (NavigationRuleType) navCase.eContainer(); - (rule).getNavigationCase().remove(navCase); - if (rule.getNavigationCase().size() == 0) { - facesConfig.getNavigationRule().remove(rule); - } - } - - /** - * Remove a link in pageflow model. - * - * @param pLink - */ - private void removeLink(PageflowLink pLink) { - // Link - PageflowPage source = (PageflowPage) pLink.getSource(); - PageflowPage target_ = (PageflowPage) pLink.getTarget(); - pLink.getPageflow().getLinks().remove(pLink); - source.getOutlinks().remove(pLink); - target_.getInlinks().remove(pLink); - // Navigation case - pLink.getFCElements().clear(); - cleanPage(source); - cleanPage(target_); - } - - /** - * Remove a link in pageflow model. - * - * @param pLink - */ - void changePFLinkStart(PageflowLink pLink, String newValue) { - PageflowPage newPage = null; - if ((newPage = getValidPFPageInCache(newValue)) != null) { - if (newValue.equals(((PageflowPage) pLink.getSource()).getPath())) { - return; - } - } else if ((newPage = TransformUtil.findPage(newValue, pageflow)) == null) { - return; - } - - // remove old case - NavigationCaseType caseType = (NavigationCaseType) pLink - .getFCElements().getData().get(0); - //NavigationRuleType rule = (NavigationRuleType) caseType.eContainer(); - removeCase(caseType); - - // create new rule / case - NavigationCaseType newCase = FacesConfigFactory.eINSTANCE - .createNavigationCaseType(); - ToViewIdType toView = FacesConfigFactory.eINSTANCE.createToViewIdType(); - toView.setTextContent(caseType.getToViewId().getTextContent()); - newCase.setToViewId(toView); - - NavigationRuleType newRule = FacesConfigFactory.eINSTANCE - .createNavigationRuleType(); - FromViewIdType fromView = FacesConfigFactory.eINSTANCE - .createFromViewIdType(); - fromView.setTextContent(newValue); - newRule.setFromViewId(fromView); - newRule.getNavigationCase().add(newCase); - facesConfig.getNavigationRule().add(newRule); - - // update - // updateNode(rule, newRule); - updateNode(caseType, newCase); - - pLink.getFCElements().clear(); - pLink.getFCElements().add(newCase); - pLink.setSource(newPage); - - updatePageflowElements(pageflow, newCase); - } - - private void updateNode(EObject old, EObject newOne) { - if (old instanceof NavigationRuleType) { - ((NavigationRuleType) newOne).getDescription().clear(); - ((NavigationRuleType) newOne).getDescription().addAll( - ((NavigationRuleType) old).getDescription()); - ((NavigationRuleType) newOne).getDisplayName().clear(); - ((NavigationRuleType) newOne).getDisplayName().addAll( - ((NavigationRuleType) old).getDisplayName()); - ((NavigationRuleType) newOne).getDescription().clear(); - ((NavigationRuleType) newOne).getIcon().clear(); - ((NavigationRuleType) newOne).getIcon().addAll( - ((NavigationRuleType) old).getIcon()); - } else if (old instanceof NavigationCaseType) { - ((NavigationCaseType) newOne).getDescription().clear(); - ((NavigationCaseType) newOne).getDescription().addAll( - ((NavigationCaseType) old).getDescription()); - ((NavigationCaseType) newOne).getDisplayName().clear(); - ((NavigationCaseType) newOne).getDisplayName().addAll( - ((NavigationCaseType) old).getDisplayName()); - ((NavigationCaseType) newOne).getDescription().clear(); - ((NavigationCaseType) newOne).getIcon().clear(); - ((NavigationCaseType) newOne).getIcon().addAll( - ((NavigationCaseType) old).getIcon()); - ((NavigationCaseType) newOne) - .setFromAction(((NavigationCaseType) old).getFromAction()); - ((NavigationCaseType) newOne) - .setFromOutcome(((NavigationCaseType) old).getFromOutcome()); - } - } - - void changePFLinkEnd(PageflowLink pLink, String newValue) { - PageflowPage newPage = null; - if ((newPage = getValidPFPageInCache(newValue)) != null) { - if (newValue.equals(((PageflowPage) pLink.getSource()).getPath())) { - return; - } - } else if ((newPage = TransformUtil.findPage(newValue, pageflow)) == null) { - return; - } - - // remove old case - NavigationCaseType caseType = (NavigationCaseType) pLink - .getFCElements().getData().get(0); - ToViewIdType toView = caseType.getToViewId(); // FacesConfigFactory.eINSTANCE.createToViewIdType(); - if (toView == null) { - toView = FacesConfigFactory.eINSTANCE.createToViewIdType(); - } - toView.setTextContent(newValue); - caseType.setToViewId(toView); - - pLink.setTarget(newPage); - - updatePageflowElements(pageflow, caseType); - } - - void removeLink(NavigationCaseType caseType) { - PageflowLink link = (PageflowLink) mapCases2Links.get(caseType); - if (link != null) { - removeLink(link); - } - } - - void addLink(PageflowPage source, PageflowPage target_, PageflowLink value) { - if (source != null && target_ != null && value != null) { - createFacesCase(value, source, target_); - } - } - - private void cleanPage(PageflowPage source) { - if (source.getInlinks().size() == 0 && source.getOutlinks().size() == 0) { - removePageflowPage(source); - } - source.update(); - } - - void refreshPFAdapter(EObject object) { - TreeIterator content = object.eAllContents(); - while (content.hasNext()) { - Object next = content.next(); - adapt((EObject) next); - } - adapt(object); - } - - void refreshFCAdapter(EObject object) { - List rules = facesConfig.getNavigationRule(); - if (rules != null) { - for (int i = 0; i < rules.size(); i++) { - NavigationRuleType rule = (NavigationRuleType) rules.get(i); - adapt(rule); - TreeIterator children = rule.eAllContents(); - while (children.hasNext()) { - adapt((EObject) children.next()); - } - } - } - adapt(facesConfig); - } - - public void setFacesConfig(FacesConfigType facesConfig) { - this.facesConfig = facesConfig; - refreshFCAdapter(facesConfig); - } - - public void setPageflow(Pageflow pageflow) { - this.pageflow = pageflow; - pageflow.eAdapters().add(this); - refreshPFAdapter(pageflow); - } - - /** - * Install compatible synchronization adapter for particular object. - * - * @param object - */ - public void adapt(EObject object) { - if (object != null && !isAdapted(object)) { - if (object instanceof PageflowElement) { - object.eAdapters().add(new PF2FCSynchronizer(this)); - } else { - object.eAdapters().add(new FC2PFSynchronizer(this)); - } - } - } - - /** - * Remove the synchronization adapter. - * - * @param object - */ - public void unAdapt(EObject object) { - Iterator adapters = object.eAdapters().iterator(); - while (adapters.hasNext()) { - Object adapter = adapters.next(); - if (adapter instanceof FC2PFSynchronizer - || adapter instanceof PF2FCSynchronizer) { - adapters.remove(); - } - } - } - - public boolean isAdapted(EObject object) { - if (object != null) { - Iterator adapters = object.eAdapters().iterator(); - while (adapters.hasNext()) { - Object adapter = adapters.next(); - if (adapter instanceof FC2PFSynchronizer - || adapter instanceof PF2FCSynchronizer) { - return true; - } - } - } - return false; - } - - public void clearCaches() { - mapPaths2PF.clear(); - mapCases2Links.clear(); - } - - /** - * dispose of this object. - */ - public void dispose() { - clearCaches(); - Pageflow pageFlow = getPageflow(); - - if (pageFlow != null) - { - pageFlow.dispose(); - } - } - - public Notifier getTarget() { - return null; - } - - public boolean isAdapterForType(Object type) { - return false; - } - - public void setTarget(Notifier newTarget) { - // do nothing - } - - public static FromViewIdType getSource(NavigationCaseType caseType) { - if (caseType.eContainer() instanceof NavigationRuleType) { - NavigationRuleType rule = (NavigationRuleType) caseType - .eContainer(); - return rule.getFromViewId(); - } - return null; - } - - private PageflowPage getOrCreateStartPage(NavigationCaseType navCase) {// FromViewIdType - PageflowPage startPageflowNode = null; - String path = "*"; - NavigationRuleType rule = (NavigationRuleType) navCase.eContainer(); - FromViewIdType source = getSource(navCase); - if (source != null) { - path = source.getTextContent(); - } - if (getValidPFPageInCache(path) == null) { - startPageflowNode = TransformUtil.findPage(path, pageflow); - - if (startPageflowNode == null) { - // not exist or is "*" - if (DEBUG) - System.out.println("Create new start page"); - startPageflowNode = createPFPage(path); - pageflowChanged = true; - } - mapPaths2PF.put(path, startPageflowNode); - PageflowTransform.getInstance().updatePageflowSourcePage( - startPageflowNode, rule); - } else { - startPageflowNode = (PageflowPage) mapPaths2PF.get(path); - } - if (source != null) { - ReferenceElement element = new PageReferenceElement( - startPageflowNode); - element.add(source); - startPageflowNode - .setReferenceLink(element.resolveReferenceString()); - startPageflowNode.getFCElements().add(source); - } - return startPageflowNode; - } - - /** - * Search for an existing pageflow page matching to navigation case's - * target, if there is no such page existing, create one. - * - * @param navCase - * @return - */ - private PageflowPage getOrCreateEndPage(NavigationCaseType navCase) { - PageflowPage endPageflowNode = null; - ToViewIdType target_ = navCase.getToViewId(); - if (target_ != null) { - String path = target_.getTextContent(); - if (getValidPFPageInCache(path) == null) { - endPageflowNode = TransformUtil.findPage(path, pageflow); - if (endPageflowNode == null) { - endPageflowNode = createPFPage(path); - if (DEBUG) - System.out.println("Create new end page"); - pageflowChanged = true; - } - mapPaths2PF.put(path, endPageflowNode); - PageflowTransform.getInstance().updatePageflowTargetPage( - endPageflowNode, navCase); - } else { - endPageflowNode = (PageflowPage) mapPaths2PF.get(path); - } - if (target_ != null) { - ReferenceElement element = new PageReferenceElement( - endPageflowNode); - element.add(target_); - endPageflowNode.setReferenceLink(element - .resolveReferenceString()); - endPageflowNode.getFCElements().add(target_); - } - } - return endPageflowNode; - } - - /** - * Return a valid cached pageflow node. - * - * @param key - * @return - */ - private PageflowPage getValidPFPageInCache(Object key) { - EObject element = (EObject) mapPaths2PF.get(key); - if (!TransformUtil.isValidPageflowElement(element) - || !(element instanceof PageflowPage) - || !((PageflowPage) element).getPath().equals(key)) { - mapPaths2PF.remove(key); - element = null; - } - return (PageflowPage) element; - } - - /** - * Return a valid cached pageflow link. - * - * @param caseType - * @return - */ - private PageflowLink getValidPFLinkInCache(EObject caseType) { - PageflowLink link = (PageflowLink) mapCases2Links.get(caseType); - if (!TransformUtil.isValidLink(link)) { - mapCases2Links.remove(caseType); - link = null; - } - return link; - - } - - /** - * Update pageflow model elements against faces-config navigation case. - */ - public boolean updatePageflowElements(Pageflow pageflow_, - NavigationCaseType caseFC) { - this.pageflowChanged = false; - this.pageflow = pageflow_; - ToViewIdType target_ = caseFC.getToViewId(); - if (target_ == null) { - return false; - } - - PageflowPage start = null, end = null; - // start page - start = getOrCreateStartPage(caseFC); - String action = null; - // action - if (caseFC.getFromAction() != null) { - action = caseFC.getFromAction().getTextContent(); - } - // from outcome - String fromOutCome = null; - if (caseFC.getFromOutcome() != null) { - fromOutCome = caseFC.getFromOutcome().getTextContent(); - } - // end page - end = getOrCreateEndPage(caseFC); - // link - // Is there a link in pageflow model? - PageflowLink link = null; - if ((link = findUnmappedLink(start, end, caseFC)) == null) { - if (end != null) { - if (DEBUG) - System.out.println("Create new link"); - link = createPFLink(start, end, action, fromOutCome); - pageflowChanged = true; - } - } - if (link != null) { - link.getFCElements().clear(); - link.getFCElements().add(caseFC); - mapCases2Links.put(caseFC, link); - } - adapt(start); - adapt(end); - adapt(caseFC); - adapt(link); - return pageflowChanged; - } - - private boolean cleanPageflowNavigationRule(Pageflow pageflow_) { - boolean dirty = false; - List links = pageflow_.getLinks(); - Iterator linksIterator = links.iterator(); - while (linksIterator.hasNext()) { - PageflowLink link = (PageflowLink) linksIterator.next(); - if (link.getFCElements().isEmpty()) { - linksIterator.remove(); - if (link.getSource() != null) { - link.getSource().getOutlinks().remove(link); - } - if (link.getTarget() != null) { - link.getTarget().getInlinks().remove(link); - } - dirty = true; - } - } - return dirty; - } - - /** - * merge the two navigation rules list between pageflow and face-config - * file. merge rule: 1. if the from-view-id, from-action, and from-outcome - * are same, they are the same navigation case, then the navigation case in - * face-config file should be updated by one in the pageflow. 2. otherwise - * the new navigation case should be created. - * - * FIXME: Not merge, only update page flow from faces-config. - * - * @param rulesFC - - * navigation rules in faces-config. - * @param navigationRulesInPageflow - - * navigation rules in pageflow model. - * - * @return boolean - whether add a new rule or not. - */ - private boolean updateNavigationRulesInPageflowFromFacesConfig(List rulesFC) { - boolean isNew = false; - // if the faces-config file is empty, the links should be removed. - if (rulesFC == null || rulesFC.isEmpty()) { - for (Iterator iterLink = pageflow.getLinks().iterator(); iterLink - .hasNext();) { - PageflowLink link = (PageflowLink) iterLink.next(); - link.getSource().getOutlinks().remove(link); - link.getTarget().getInlinks().remove(link); - } - pageflow.getLinks().clear(); - } else { - // Rule - Cases - for (Iterator iterRulesFC = rulesFC.iterator(); iterRulesFC - .hasNext();) { - NavigationRuleType ruleFC = (NavigationRuleType) iterRulesFC - .next(); - - List casesFC = ruleFC.getNavigationCase(); - for (Iterator iterCasesFC = casesFC.iterator(); iterCasesFC - .hasNext();) { - NavigationCaseType navigationCaseFC = (NavigationCaseType) iterCasesFC - .next(); - isNew |= updatePageflowElements(pageflow, navigationCaseFC); - } - } - } - isNew |= cleanPageflowNavigationRule(pageflow); - return isNew; - } - - /** - * Find a pageflow link that is not linked to a faces-config element. Since - * user might edit faces-config file with other editor, so the path is not - * always valid, here we still try to match link and navigation case. TODO: - * should we always resolve mapping from referenceLink on PageflowElement? - */ - private PageflowLink findUnmappedLink(PageflowPage start, PageflowPage end, - NavigationCaseType caseFC) { - List links = start.getOutlinks(); - for (int i = 0, n = links.size(); i < n; i++) { - PageflowLink link = (PageflowLink) links.get(i); - if (link.getSource() == start && link.getTarget() == end) { - link.update(); - if (link.getFCElements().isEmpty() - || link.getFCElements().getData().get(0) == caseFC) { - return link; - } - } - } - return null; - } - - public PageflowLink createPFLink(PageflowNode start, PageflowNode target_, - NavigationCaseType caseFC) { - PageflowLink link = null; - String fromOutcome = caseFC.getFromOutcome() != null ? caseFC - .getFromOutcome().getTextContent() : null; - String action = caseFC.getFromAction() != null ? caseFC.getFromAction() - .getTextContent() : null; - NavigationRuleType rule = (NavigationRuleType) caseFC.eContainer(); - link = createPFLink(fromOutcome); - link.setFromaction(action); - link.setSource(start); - link.setTarget(target_); - start.getOutlinks().add(link); - target_.getInlinks().add(link); - // The reference. - link.getFCElements().add(caseFC); - start.getFCElements().add(rule.getFromViewId()); - target_.getFCElements().add(caseFC.getToViewId()); - return link; - } - - /** - * create a new PFLink object according to fromOutcome attribute - * - * @param fromOutcome - - * PFLink's fromOutcome attribute - * @return - new PFLink object - */ - public PageflowLink createPFLink(String fromOutcome) { - PageflowLink link = null; - link = PageflowModelManager.getFactory().createPFLink(); - if (fromOutcome != null && fromOutcome.length() > 0) { - link.setOutcome(fromOutcome.trim()); - } - pageflow.getLinks().add(link); - return link; - } - - /** - * create a new PFLink object according to fromOutcome attribute - * - * @param fromOutcome - - * PFLink's fromOutcome attribute - * @return - new PFLink object - */ - public PageflowLink createPFLink(PageflowNode start, PageflowNode target_, - String action, String fromOutcome) { - Assert.isTrue(start != null && target_ != null); - PageflowLink link = null; - link = createPFLink(fromOutcome); - link.setFromaction(action); - link.setSource(start); - link.setTarget(target_); - start.getOutlinks().add(link); - target_.getInlinks().add(link); - return link; - } - - /** - * Create a new PFPage according to from-view-id - * - * @param fromViewID - - * page's from-view-id - * @return the page flow page - */ - public PageflowPage createPFPage(String fromViewID) { - PageflowPage page = PageflowFactory.eINSTANCE.createPFPage(); - if (fromViewID != null && fromViewID.length() > 0) { - page.setPath(fromViewID.trim()); - page.setName(WebrootUtil.getPageNameFromWebPath(fromViewID.trim())); - } - this.pageflow.getNodes().add(page); - return page; - } - - /** - * update pageflow model according to the face-config model - * - * @author sfshi - * @return true if new rules were added - */ - public boolean updatePageflowModelFromEMF() { - if (pageflow != null && facesConfig != null) { - List navigationRulesInFacesconfig = facesConfig.getNavigationRule(); - clearCaches(); - // if add new one, we can relayout the current pageflow. - return updateNavigationRulesInPageflowFromFacesConfig(navigationRulesInFacesconfig); - } - return false; - } - - void refreshLink(NavigationCaseType caseType) { - PageflowLink link = getValidPFLinkInCache(caseType); - if (link != null) { - removeLink(link); - } - // update pageflow - if (TransformUtil.isValidFacesConfigElement(caseType)) { - updatePageflowElements(pageflow, caseType); - } - } - - public void notifyChanged(Notification msg) { - int type = msg.getEventType(); - switch (type) { - case MY_NOTIFICATION_TYPE: - setNeedBatchOperations(true); - break; - case MY_NOTIFICATION_TYPE1: - setNeedBatchOperations(false); - } - } - - public boolean isListenToNotify() { - return listenToNotify && !isInEvent; - } - - public boolean isInEvent() { - return isInEvent; - } - - public void setInEvent(boolean isInEvent) { - this.isInEvent = isInEvent; - } - - public FacesConfigType getFacesConfig() { - return facesConfig; - } - - public Pageflow getPageflow() { - return pageflow; - } - - public static FromViewIdType createRLFromViewID(String value) { - FromViewIdType fromView = FacesConfigFactory.eINSTANCE - .createFromViewIdType(); - fromView.setTextContent(value); - return fromView; - } - - public static ToViewIdType createFCToViewID(String value) { - ToViewIdType toView = FacesConfigFactory.eINSTANCE.createToViewIdType(); - toView.setTextContent(value); - return toView; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/PF2FCSynchronizer.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/PF2FCSynchronizer.java deleted file mode 100644 index c446c0a66..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/PF2FCSynchronizer.java +++ /dev/null @@ -1,215 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.synchronization; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.Notifier; -import org.eclipse.emf.common.notify.impl.AdapterImpl; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.jst.jsf.common.ui.internal.logging.Logger; -import org.eclipse.jst.jsf.facesconfig.emf.NavigationCaseType; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; - -/** - * The adapter that listens to modification of pageflow and updates faces-config - * as needed. - * - * @author hmeng - * - */ -public class PF2FCSynchronizer extends AdapterImpl { - FC2PFTransformer tranformer; - - private final boolean DEBUG = false; - - private static final Logger logger = EditorPlugin - .getLogger(PF2FCSynchronizer.class); - - public PF2FCSynchronizer(FC2PFTransformer tranformer) { - this.tranformer = tranformer; - } - - public Notifier getTarget() { - // TODO Auto-generated method stub - return null; - } - - public void setTarget(Notifier newTarget) { - // TODO Auto-generated method stub - - } - - public boolean isAdapterForType(Object type) { - return type == PF2FCSynchronizer.class; - } - - public void notifyChanged(Notification notification) { - if (!isProcessorFor(notification)) { - return; - } - tranformer.setInEvent(true); - try { - if (!(notification.getNotifier() instanceof PageflowElement)) { - return; - } - processChange(notification); - } catch (Exception e) { - logger.error(e); - } finally { - if (notification.getEventType() != Notification.REMOVING_ADAPTER) { - tranformer.refreshPFAdapter(tranformer.getPageflow()); - tranformer.refreshFCAdapter(tranformer.getFacesConfig()); - } - tranformer.setInEvent(false); - } - } - - private boolean isProcessorFor(Notification notification) { - return tranformer.isListenToNotify(); - } - - private void processChange(Notification notification) { - PageflowElement element; - element = (PageflowElement) notification.getNotifier(); - int type = notification.getEventType(); - switch (type) { - case Notification.ADD: { - int featureId = notification.getFeatureID(PageflowPackage.class); - switch (featureId) { - case PageflowPackage.PAGEFLOW_NODE__OUTLINKS: - addOutLink(notification, element); - break; - case PageflowPackage.PAGEFLOW_NODE__INLINKS: - addInLink(notification, element); - break; - case PageflowPackage.PAGEFLOW: - break; - } - if (!tranformer.isNeedBatchOperations()) { - updateAndNotify(notification); - } - break; - } - case Notification.SET: - if (notification.getNewValue() != null) { - processSet(notification, element); - updateAndNotify(notification); - } - break; - case Notification.REMOVE: - case Notification.REMOVE_MANY: { - int featureId = notification.getFeatureID(PageflowPackage.class); - switch (featureId) { - case PageflowPackage.PF_PAGE: - // removePage(notification, (PageflowPage) element); - break; - case PageflowPackage.PAGEFLOW_NODE__OUTLINKS: - case PageflowPackage.PAGEFLOW_NODE__INLINKS: - removeLink(notification, element); - break; - } - if (!tranformer.isNeedBatchOperations()) { - updateAndNotify(notification); - } - break; - } - } - } - - private void processSet(Notification notification, PageflowElement element) { - if (notification.getNewValue() != null) { - int value = notification.getFeatureID(PageflowPackage.class); - if (element instanceof PageflowPage) { - setProperties(notification, element, value); - } else if (element instanceof PageflowLink) { - if (DEBUG) - System.out.println("The link property is changed"); - setProperties(notification, element, value); - } - } - } - - private void setProperties(Notification notification, - PageflowElement element, int value) { - if (notification.getFeature() == PageflowPackage.eINSTANCE - .getPFLink_Source()) { - if (notification.getNewValue() instanceof String) { - tranformer.changePFLinkStart((PageflowLink) element, - (String) notification.getNewValue()); - } - } else if (notification.getFeature() == PageflowPackage.eINSTANCE - .getPFLink_Target()) { - if (notification.getNewValue() instanceof String) { - tranformer.changePFLinkEnd((PageflowLink) element, - (String) notification.getNewValue()); - } - } else { - element.getFCElements().set( - (EStructuralFeature) notification.getFeature(), - notification.getNewValue()); - } - } - - private void addInLink(Notification notification, PageflowElement element) { - Object value = notification.getNewValue(); - PageflowLink link = (PageflowLink) value; - if (element instanceof PageflowPage) { - PageflowNode source = link.getSource(); - if (source instanceof PageflowPage) { - tranformer.addLink((PageflowPage) source, - (PageflowPage) element, link); - } - } - - } - - private void addOutLink(Notification notification, PageflowElement element) { - Object value = notification.getNewValue(); - // for outLink remove, only target is referenced. - PageflowLink link = (PageflowLink) value; - if (element instanceof PageflowPage) { - PageflowNode target_ = link.getTarget(); - // page->page - if (target_ instanceof PageflowPage) { - tranformer.addLink((PageflowPage) element, - (PageflowPage) target_, link); - } - } - } - - private void removeLink(Notification notification, PageflowElement element) { - Object value = notification.getOldValue(); - PageflowLink link = (PageflowLink) value; - - if (!link.getFCElements().isEmpty()) { - NavigationCaseType caseFC = (NavigationCaseType) link - .getFCElements().getData().get(0); - if (caseFC != null) - tranformer.removeCase(caseFC); - } - link.update(); - } - - private void updateAndNotify(Notification notification) { - tranformer.getPageflow().notifyModelChanged( - new ENotificationImpl((InternalEObject) notification - .getNotifier(), Notification.SET, - PageflowPackage.PAGEFLOW, null, null)); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/PFBatchAdapter.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/PFBatchAdapter.java deleted file mode 100644 index 5b1c148c0..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/PFBatchAdapter.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.synchronization; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.impl.AdapterImpl; -import org.eclipse.gef.editparts.AbstractGraphicalEditPart; - -/** - * @author hmeng - */ - -public abstract class PFBatchAdapter extends AdapterImpl { - private boolean needPostpone; - - AbstractGraphicalEditPart editPart; - - public boolean isNeedPostpone(Notification msg) { - return needPostpone - && !(msg.getEventType() == FC2PFTransformer.MY_NOTIFICATION_TYPE || msg - .getEventType() == FC2PFTransformer.MY_NOTIFICATION_TYPE1); - } - - public void setNeedPostpone(boolean needPostpone) { - this.needPostpone = needPostpone; - } - - public AbstractGraphicalEditPart getEditPart() { - return editPart; - } - - public void setEditPart(AbstractGraphicalEditPart editPart) { - this.editPart = editPart; - } - - final public void notifyChanged(Notification msg) { - if (!isNeedPostpone(msg)) { - doNotifyChanged(msg); - } - } - - abstract public void doNotifyChanged(Notification notification); - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/TransformUtil.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/TransformUtil.java deleted file mode 100644 index 39b447bca..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/synchronization/TransformUtil.java +++ /dev/null @@ -1,104 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.synchronization; - -import java.util.List; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigType; -import org.eclipse.jst.jsf.facesconfig.emf.FromOutcomeType; -import org.eclipse.jst.jsf.facesconfig.emf.NavigationCaseType; -import org.eclipse.jst.jsf.facesconfig.emf.NavigationRuleType; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; - -/** - * The util for pageflow and faces-config transforming - * - * @author hmeng - */ - -public class TransformUtil { - - /** - * To see if the faces-config element is on a valid hirachy. - */ - public static boolean isValidFacesConfigElement(EObject object) { - EObject parent = EcoreUtil.getRootContainer(object); - boolean result = parent instanceof FacesConfigType; - return result; - } - - /** - * To see if the pageflow element is on a valid hirachy. - */ - public static boolean isValidPageflowElement(EObject element) { - EObject root = EcoreUtil.getRootContainer(element); - boolean result = root instanceof Pageflow; - return result; - } - - public static boolean isValidLink(PageflowLink link) { - return isValidPageflowElement(link) && link.getSource() != null - && link.getTarget() != null; - } - - public static String getFromViewID(NavigationRuleType rule) { - String result = "*"; - if (rule.getFromViewId() != null) { - result = rule.getFromViewId().getTextContent(); - } - return result; - } - - public static String getToViewID(NavigationCaseType navCase) { - String result = "*"; - if (navCase.getToViewId() != null) { - result = navCase.getToViewId().getTextContent(); - } - return result; - } - - public static PageflowPage findPage(String path, Pageflow pageflow) { - List nodes = pageflow.getNodes(); - for (int i = 0; i < nodes.size(); i++) { - if (nodes.get(i) instanceof PageflowPage) { - if (path != null) { - if (path.equals(((PageflowPage) nodes.get(i)).getPath())) { - return (PageflowPage) nodes.get(i); - } - } - } - } - return null; - } - - public static PageflowNode findCaseEnd(PageflowPage action, - FromOutcomeType outcome, Pageflow pageflow) { - // TODO: find a case end in pageflow model - List links = action.getOutlinks(); - for (int i = 0; i < links.size(); i++) { - PageflowLink link = (PageflowLink) links.get(i); - String outcomeStr = ""; - if (outcome != null) { - outcomeStr = outcome.getTextContent(); - } - if (link.getOutcome().equals(outcomeStr)) { - return link.getTarget(); - } - } - return null; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/EditPartMarkerUtil.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/EditPartMarkerUtil.java deleted file mode 100644 index a1e3c645b..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/EditPartMarkerUtil.java +++ /dev/null @@ -1,216 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.util; - -import java.util.Iterator; - -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement; -import org.eclipse.jst.jsf.facesconfig.ui.util.WebrootUtil; - -/** - * - * Utility class to add and remove edit part markers. - * - * FIXME: add the identification mechanism of the model and remove the - * dependency on the PageflowElement - * - * @author Xiao-guang Zhang - * - * - */ -public class EditPartMarkerUtil { - - /** - * Removes all markers that were created using createMarker() - * - * @param model - - * the emf model related with edit part - * @throws CoreException - */ - public static void removeAllMarkers(EObject model) throws CoreException { - IResource resource = getResource(model); - - if (resource != null) { - String markerTypes[] = { IMarker.PROBLEM, IMarker.TASK }; - - for (int iMT = 0; iMT < markerTypes.length; iMT++) { - IMarker[] markers = resource.findMarkers(markerTypes[iMT], - false, IResource.DEPTH_ONE); - - for (int iMark = 0; iMark < markers.length; iMark++) { - markers[iMark].delete(); - } - } - } - } - - /** - * Removes a specific problem marker type with the given severity. - * - * @param model - - * the model related with this edit part. - * @param sMarkerType - - * the marker type, either IMarker.PROBLEM or IMarker.TASK - * @param iSeverity - - * severity/priority: if sMarkerType is IMarker.PROBLEM, then - * this value is one of the PROBLEM severities; if sMarkerType is - * IMarker.TASK, this is a task priority. - * @throws CoreException - * passed on from IResource.findMarkers() - */ - public static void removeAllMarkers(EObject model, String sMarkerType, - int iSeverity) throws CoreException { - IResource resource = getResource(model); - - if (resource != null) { - IMarker[] markers = resource.findMarkers(sMarkerType, false, - IResource.DEPTH_ONE); - - for (int i = 0; i < markers.length; i++) { - IMarker marker = markers[i]; - int iMarkerSeverity = marker.getAttribute(IMarker.SEVERITY, - IMarker.SEVERITY_ERROR); - - if (iMarkerSeverity == iSeverity || iSeverity == -1) { - markers[i].delete(); - } - } - } - } - - /** - * get the resouce according to part or model. - * - * @param part - * @param model - * @return - */ - private static IResource getResource(EObject model) { - IResource resource = null; - resource = WebrootUtil.getResource(model); - return resource; - } - - /** - * Create a problem marker. - * - * @param model - - * the model related with this edit part. - * @param sMarkerType - * @param severity - - * the problem severity, one of IMarker.SEVERITY_ERROR, - * IMarker.SEVERITY_WARNING or IMarker.SEVERITY_INFO - * @param message - - * the text associated with this marker - * @param location - - * a unique ID that the application can use to locate the - * editpart - * - * that corresponds to this marker; this is typically the DiagramElement's - * ID string - * @throws CoreException - */ - public static void createMarker(EObject model, String sMarkerType, - int severity, String message, String location) throws CoreException { - IResource resource = getResource(model); - - if (resource != null) { - IMarker marker = resource.createMarker(sMarkerType); - marker.setAttribute(IMarker.MESSAGE, message); - marker.setAttribute(IMarker.SEVERITY, severity); - // The problem view doesn't show the location - only the line number - // is shown in the "location" column. Doh! - if (location != null && location.length() > 0) { - marker.setAttribute(IMarker.LOCATION, location); - } - } - } - - /** - * Removes a specific problem marker type with the given severity. - * - * @param model - - * the model related with this edit part. - * @param sMarkerType - - * the marker type, either IMarker.PROBLEM or IMarker.TASK - * @throws CoreException - * passed on from IResource.findMarkers() - */ - public static void removeMarker(EObject model, String sMarkerType) - throws CoreException { - IResource resource = getResource(model); - if (resource != null) { - IMarker[] markers = resource.findMarkers(sMarkerType, false, - IResource.DEPTH_ONE); - - for (int i = 0; i < markers.length; i++) { - IMarker marker = markers[i]; - // get the marker's location - Object id = marker.getAttribute(IMarker.LOCATION); - - if (model instanceof PageflowElement) { - if (((PageflowElement) model).getId().equals(id)) { - markers[i].delete(); - } - } - } - } - } - - /** - * Searches the hierarchy starting at the given EditPart for a given model - * object ID string (the DiagramElement.ID value) and returns that EditPart - * - * @param containerPart - * @param id - * @return the EditPart that corresponds to the given ID string, or null if - * not found - */ - public static GraphicalEditPart findEditPart( - GraphicalEditPart containerPart, String id) { - Object model = containerPart.getModel(); - if (model instanceof PageflowElement) { - String modelId = ((PageflowElement) model).getId(); - if (modelId != null && modelId.equals(id)) { - return containerPart; - } - } - - Iterator iterNode = containerPart.getChildren().iterator(); - while (iterNode.hasNext()) { - GraphicalEditPart child = (GraphicalEditPart) iterNode.next(); - GraphicalEditPart foundPart = findEditPart(child, id); - if (foundPart != null) { - return foundPart; - } - } - - Iterator iterConnection = containerPart.getSourceConnections() - .iterator(); - while (iterConnection.hasNext()) { - GraphicalEditPart child = (GraphicalEditPart) iterConnection.next(); - GraphicalEditPart foundPart = findEditPart(child, id); - if (foundPart != null) { - return foundPart; - } - } - - return null; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/JSPDomAdapter.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/JSPDomAdapter.java deleted file mode 100644 index 0954c3c12..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/JSPDomAdapter.java +++ /dev/null @@ -1,204 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.util; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jst.jsf.common.ui.internal.logging.Logger; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.wst.sse.core.StructuredModelManager; -import org.eclipse.wst.sse.core.internal.provisional.IModelManager; -import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; -import org.w3c.dom.Document; -import org.w3c.dom.NodeList; - -/** - * This class is defined as a simple adapter to JSP DOM model. User can get the - * taglib prefix, and get the needed element by element tage name, and - * namespace(prefix) Usage: User should initialize this class instance before - * using it. Following is a typical example: JSPDomAdapter jspAdapter = new - * JSPDomAdapter(); IFile jspFile = - * ResourcesPlugin.getWorkspace().getRoot().getFile(jspPath); if - * (_jspAdapter.initialize(jspFile)) { //the prefix of JSF HTML TagLib String - * prefix = _jspAdapter.getTagLibPrefix(JSPDomAdapter.JSF_HTML_TAGLIB); } - * - * @author Xiao-guang Zhang - */ -public class JSPDomAdapter { - /** log instance */ - private static final Logger log = EditorPlugin - .getLogger(JSPDomAdapter.class); - - /** JSP Taglib's tag name */ - public static String JSP_TAGLIB_TAG = "jsp:directive.taglib"; - - /** JSF HTML TagLib name */ - public static String JSF_HTML_TAGLIB = "http://java.sun.com/jsf/html"; - - /** singleton model manager */ - private static IModelManager modelManager; - - /** source jsp file */ - private IFile jspFile; - - /** Structured Model of JSP File */ - private IStructuredModel model; - - /** Root Document (Node) of JSP file */ - private Document document; - - /** - * - */ - public JSPDomAdapter() { - super(); - - } - - /** - * initialize this adapter to get the StructuredModel for the input file. - * At last user should call releaseModel() method to release the Structured Model. - * - * @param file - - * JSP file - * @return - True means sucessfully load jsp file. - */ - public boolean initialize(IFile file) { - jspFile = file; - - if (jspFile != null && jspFile.exists()) { - try { - model = getModel(jspFile); - } catch (IOException e) { - // PageFlow.JSPDomAdapter.FailToGetStructuredModel = Failed to - // get the structured model - log.error("PageFlow.JSPDomAdapter.FailToGetStructuredModel", e); //$NON-NLS-1$ - } catch (CoreException e) { - // PageFlow.JSPDomAdapter.FailToGetStructuredModel = Failed to - // get the structured model - log.error("PageFlow.JSPDomAdapter.FailToGetStructuredModel", e);//$NON-NLS-1$ - } - - if (model != null && model instanceof IDOMModel) { - return true; - } - } - - return false; - } - - /** - * get the prefix for the input taglib URI, e.g., - * http://java.sun.com/jsf/html -> "h" - * - * @param taglibURI - * @return the prefix - */ - public String getTagLibPrefix(String taglibURI) { - String prefix = null; - - if (getDocument() != null) { - prefix = JSPUtil.getPrefix((IDOMModel) model, taglibURI); - } - - return prefix; - } - - /** - * get the elements by the namespace and its tag name, e.g., h and - * commandButton. - * - * @param namespace - - * namespace for the taglib, e.g., h for - * http://java.sun.com/jsf/html - * @param elementName - - * element Tag Name, e.g., h - * @return - Element Node list. - */ - public List getElementsByTagNameNS(String namespace, String elementName) { - List nodes = null; - - if (getDocument() != null) { - NodeList listNodes = null; - if (namespace != null) { - listNodes = getDocument().getElementsByTagName( - namespace + ":" + elementName); //$NON-NLS-1$ - } else { - listNodes = getDocument().getElementsByTagName(elementName); //$NON-NLS-1$ - } - - if (listNodes != null && listNodes.getLength() > 0) { - nodes = new ArrayList(); - for (int i = 0; i < listNodes.getLength(); i++) { - nodes.add(listNodes.item(i)); - } - } - } - return nodes; - } - - /** - * get the singleton model manager. - * - * @return - */ - private IModelManager getModelManager() { - if (modelManager == null) { - modelManager = StructuredModelManager.getModelManager(); - } - return modelManager; - } - - /** - * get the structured model for the JSP file - * - * @param file - - * JSP File - * @return - IStructuredModel - * @throws IOException - * @throws CoreException - */ - private IStructuredModel getModel(IFile file) throws IOException, - CoreException { - return getModelManager().getModelForRead(file); - } - - /** - * get the root docuement for the StructuredModel - * - * @return - */ - private Document getDocument() { - if (document == null) { - if (model != null && model instanceof IDOMModel) { - document = ((IDOMModel) model).getDocument(); - } - } - return document; - } - - - /** - * signal we are done with the model - */ - public void releaseModel() { - if (model != null) { - model.releaseFromRead(); - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/JSPUtil.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/JSPUtil.java deleted file mode 100644 index a50fbd191..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/JSPUtil.java +++ /dev/null @@ -1,185 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.util; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jst.jsp.core.internal.contentmodel.TaglibController; -import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TLDCMDocumentManager; -import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TaglibTracker; -import org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.TLDDocument; -import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; - -/** - * utility class for JSP related information. - * - * @author Yang Liu - */ -public class JSPUtil { - /** - * find out whether the specified taglib has been defined in the IDOMModel. - * If found, then return the prefix. If can't find, then will try to add a - * taglib declaration into the model, and try to use the specified default - * prefix - * - * @param model - * @param uri - * @param defaultPrefix - * @return the prefix if model has one or the default - */ - public static String getOrCreatePrefix(IDOMModel model, String uri, - String defaultPrefix) { - String prefix = getPrefix(model, uri); - if (prefix != null) - return prefix; - String s = findUnusedPrefix(model, defaultPrefix); - - // TODO: should create the taglib inside the IDOMModel - return s; - } - - /** - * - * @param model - * @param uri - * @return null means this is tld is not declared in the jsp file - */ - public static String getPrefix(IDOMModel model, String uri) { - TLDCMDocumentManager m = TaglibController.getTLDCMDocumentManager(model - .getStructuredDocument()); - if (m == null) - return null; - List trackers = m.getTaglibTrackers(); - for (Iterator iter = trackers.iterator(); iter.hasNext();) { - TaglibTracker tracker = (TaglibTracker) iter.next(); - if (uri.equals(tracker.getURI())) { - return tracker.getPrefix(); - } - - CMDocument cmdoc = tracker.getDocument(); - if (cmdoc instanceof TLDDocument - && uri.equals(((TLDDocument) cmdoc).getUri())) { - return tracker.getPrefix(); - } - } - return null; - } - - /** - * @param model - * @param suggestion - * @return the unsued prefix - */ - public static String findUnusedPrefix(IDOMModel model, String suggestion) { - if (suggestion == null) - suggestion = "p"; - TLDCMDocumentManager m = TaglibController.getTLDCMDocumentManager(model - .getStructuredDocument()); - if (m == null) - return suggestion; - List trackers = m.getTaglibTrackers(); - Set map = new HashSet(); - for (Iterator iter = trackers.iterator(); iter.hasNext();) { - TaglibTracker tracker = (TaglibTracker) iter.next(); - map.add(tracker.getPrefix()); - } - if (!map.contains(suggestion)) - return suggestion; - for (int i = 1;; i++) { - if (!map.contains(suggestion + i)) - return suggestion + i; - } - } - - /** - * given the prefix, find the corresponding jsp tld URI. - * - * @param model - * @param prefix - * @return the uri corresponding to the prefix - */ - public static String findURIForPrefix(IDOMModel model, String prefix) { - if (prefix == null || model == null) - return null; - TLDCMDocumentManager m = TaglibController.getTLDCMDocumentManager(model - .getStructuredDocument()); - if (m == null) - return null; - List trackers = m.getTaglibTrackers(); - for (Iterator iter = trackers.iterator(); iter.hasNext();) { - TaglibTracker tracker = (TaglibTracker) iter.next(); - if (prefix.equals(tracker.getPrefix())) { - CMDocument cmdoc = tracker.getDocument(); - if (cmdoc instanceof TLDDocument) - { - return ((TLDDocument) cmdoc).getUri(); - } - return null; - } - } - return null; - } - - /** - * get the action list in the jsp file - * @param jspFileName - * - * @return - action list - */ - public static List getActionListInJSPFile(String jspFileName) { - /** jsp dom adapter */ - JSPDomAdapter jspAdapter; - - List actions = new ArrayList(); - jspAdapter = new JSPDomAdapter(); - // convert the relative directory to project directory, e.g., /a.jsp to - // /testproject/webroot/a.sjp - String physicalJspPath = jspFileName; - if (physicalJspPath != null && physicalJspPath.length() > 0) { - IPath jspPath = new Path(physicalJspPath); - IFile jspFile = ResourcesPlugin.getWorkspace().getRoot().getFile( - jspPath); - - if (jspFile != null && jspFile.exists()) { - // initialize the adapter to initialize the model of jsp - if (jspAdapter.initialize(jspFile)) { - // the prefix of JSF HTML TagLib - String prefix = jspAdapter - .getTagLibPrefix(JSPDomAdapter.JSF_HTML_TAGLIB); - - // get the command butonns - List buttonActions = jspAdapter.getElementsByTagNameNS( - prefix, "commandButton");//$NON-NLS-1$ - if (buttonActions != null) - actions.addAll(buttonActions); - - // get the command links - List linkActions = jspAdapter.getElementsByTagNameNS( - prefix, "commandLink");//$NON-NLS-1$ - if (linkActions != null) - actions.addAll(linkActions); - } - } - } - jspAdapter.releaseModel(); - return actions; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/ModelCreationFactory.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/ModelCreationFactory.java deleted file mode 100644 index 655b4c618..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/ModelCreationFactory.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.util; - -import org.eclipse.gef.requests.CreationFactory; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowFactory; - -/** - * This class implements the CreationFactory used by the CreationTool. It in - * turn uses the EMF-generated factories to create the model instances - * - * @author Xiao-guang Zhang - */ -public class ModelCreationFactory implements CreationFactory { - private Class targetClass; - - public ModelCreationFactory(Class targetClass) { - this.targetClass = targetClass; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.requests.CreationFactory#getNewObject() - */ - public Object getNewObject() { - PageflowFactory factory = PageflowModelManager.getFactory(); - - Object result = null; - - if (targetClass.equals(PageflowLink.class)) { - result = factory.createPFLink(); - - } else if (targetClass.equals(PageflowPage.class)) { - result = factory.createPFPage(); - } - - return result; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.requests.CreationFactory#getObjectType() - */ - public Object getObjectType() { - return targetClass; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/PageflowAdapterFactory.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/PageflowAdapterFactory.java deleted file mode 100644 index 8da99bf53..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/PageflowAdapterFactory.java +++ /dev/null @@ -1,256 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.util; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notifier; -import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage; - -/** - * <!-- begin-user-doc --> The <b>Adapter Factory</b> for the model. It - * provides an adapter <code>createXXX</code> method for each class of the - * model. <!-- end-user-doc --> - * - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage - * @generated - */ -// FIXME: this appears to be a dead class. -public class PageflowAdapterFactory extends AdapterFactoryImpl { - /** - * The cached model package. <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - protected static PageflowPackage modelPackage; - - /** - * Creates an instance of the adapter factory. <!-- begin-user-doc --> <!-- - * end-user-doc --> - * - * @generated - */ - public PageflowAdapterFactory() { - if (modelPackage == null) { - modelPackage = PageflowPackage.eINSTANCE; - } - } - - /** - * Returns whether this factory is applicable for the type of the object. - * <!-- begin-user-doc --> This implementation returns <code>true</code> - * if the object is either the model's package or is an instance object of - * the model. <!-- end-user-doc --> - * - * @return whether this factory is applicable for the type of the object. - * @generated - */ - public boolean isFactoryForType(Object object) { - if (object == modelPackage) { - return true; - } - if (object instanceof EObject) { - return ((EObject) object).eClass().getEPackage() == modelPackage; - } - return false; - } - - /** - * The switch the delegates to the <code>createXXX</code> methods. <!-- - * begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - protected PageflowSwitch modelSwitch = new PageflowSwitch() { - public Object casePageflow(Pageflow object) { - return createPageflowAdapter(); - } - - public Object casePageflowNode(PageflowNode object) { - return createPageflowNodeAdapter(); - } - - public Object casePFLink(PageflowLink object) { - return createPFLinkAdapter(); - } - - public Object casePageflowElement(PageflowElement object) { - return createPageflowElementAdapter(); - } - - public Object casePFPage(PageflowPage object) { - return createPFPageAdapter(); - } - - public Object casePFLinkBendpoint(PageflowLinkBendpoint object) { - return createPFLinkBendpointAdapter(); - } - - public Object defaultCase(EObject object) { - return createEObjectAdapter(); - } - }; - - /** - * Creates an adapter for the <code>target</code>. <!-- begin-user-doc - * --> <!-- end-user-doc --> - * - * @param target - * the object to adapt. - * @return the adapter for the <code>target</code>. - * @generated - */ - public Adapter createAdapter(Notifier target) { - return (Adapter) modelSwitch.doSwitch((EObject) target); - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow <em>Pageflow</em>}'. - * <!-- begin-user-doc --> This default implementation returns null so that - * we can easily ignore cases; it's useful to ignore a case when inheritance - * will catch all the cases anyway. <!-- end-user-doc --> - * - * @return the new adapter. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow - * @generated - */ - public Adapter createPageflowAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode <em>Node</em>}'. - * <!-- begin-user-doc --> This default implementation returns null so that - * we can easily ignore cases; it's useful to ignore a case when inheritance - * will catch all the cases anyway. <!-- end-user-doc --> - * - * @return the new adapter. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode - * @generated - */ - public Adapter createPageflowNodeAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink <em>PF Link</em>}'. - * <!-- begin-user-doc --> This default implementation returns null so that - * we can easily ignore cases; it's useful to ignore a case when inheritance - * will catch all the cases anyway. <!-- end-user-doc --> - * - * @return the new adapter. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink - * @generated - */ - public Adapter createPFLinkAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement <em>Element</em>}'. - * <!-- begin-user-doc --> This default implementation returns null so that - * we can easily ignore cases; it's useful to ignore a case when inheritance - * will catch all the cases anyway. <!-- end-user-doc --> - * - * @return the new adapter. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement - * @generated - */ - public Adapter createPageflowElementAdapter() { - return null; - } - - /** - * <!-- begin-user-doc --> This default implementation returns null so that - * we can easily ignore cases; it's useful to ignore a case when inheritance - * will catch all the cases anyway. <!-- end-user-doc --> - * - * @return the new adapter. - * @generated - */ - public Adapter createPFActionAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage <em>PF Page</em>}'. - * <!-- begin-user-doc --> This default implementation returns null so that - * we can easily ignore cases; it's useful to ignore a case when inheritance - * will catch all the cases anyway. <!-- end-user-doc --> - * - * @return the new adapter. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage - * @generated - */ - public Adapter createPFPageAdapter() { - return null; - } - - /** - * <!-- begin-user-doc --> This default implementation returns null so that - * we can easily ignore cases; it's useful to ignore a case when inheritance - * will catch all the cases anyway. <!-- end-user-doc --> - * - * @return the new adapter. - * @generated - */ - public Adapter createPFBeginAdapter() { - return null; - } - - /** - * <!-- begin-user-doc --> This default implementation returns null so that - * we can easily ignore cases; it's useful to ignore a case when inheritance - * will catch all the cases anyway. <!-- end-user-doc --> - * - * @return the new adapter. - * @generated - */ - public Adapter createPFEndAdapter() { - return null; - } - - /** - * Creates a new adapter for an object of class '{@link org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint <em>PF Link Bendpoint</em>}'. - * <!-- begin-user-doc --> This default implementation returns null so that - * we can easily ignore cases; it's useful to ignore a case when inheritance - * will catch all the cases anyway. <!-- end-user-doc --> - * - * @return the new adapter. - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint - * @generated - */ - public Adapter createPFLinkBendpointAdapter() { - return null; - } - - /** - * Creates a new adapter for the default case. <!-- begin-user-doc --> This - * default implementation returns null. <!-- end-user-doc --> - * - * @return the new adapter. - * @generated - */ - public Adapter createEObjectAdapter() { - return null; - } - -} -// PageflowAdapterFactory diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/PageflowAnnotationUtil.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/PageflowAnnotationUtil.java deleted file mode 100644 index 89e6190fb..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/PageflowAnnotationUtil.java +++ /dev/null @@ -1,168 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.util; - -import java.util.Iterator; - -import org.eclipse.core.resources.IMarker; -import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.jface.text.source.Annotation; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.IAnnotationEditPart; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PFValidator; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowElementEditPart; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowLinkEditPart; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowNodeEditPart; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; - -/** - * This class can be used to add annotation for the current pageflow model and - * decoration for view. - * - * @author Xiao-guang Zhang - * - * - */ -public class PageflowAnnotationUtil { - - /** - * - * validate the pageflow and its edit part - * - * @param containerPart - - * it can be null, then the edit part will not be updated - */ - public static void validatePageflow(GraphicalEditPart containerPart) { - if (containerPart == null) { - return; - } - - // removeAllAnnotations(containerPart); - - // validate the nodes including page and actions. - Iterator iterChild = containerPart.getChildren().iterator(); - while (iterChild.hasNext()) { - - PageflowElementEditPart element = (PageflowElementEditPart) iterChild - .next(); - // String errorMessage = null; - if (element instanceof PFValidator) { - ((PFValidator) element).validate(); - } - // if (element.getModel() instanceof PageflowPage) { - // errorMessage = PageflowValidation.getInstance().getNotifyMessage( - // (PageflowPage) element.getModel()); - // } - - // if (errorMessage != null) { - // addAnnotation(element, errorMessage); - // } else { - // removeAnnotation(element); - // } - - // validate the connections. - Iterator iterLinks = element.getSourceConnections().iterator(); - while (iterLinks.hasNext()) { - PageflowLinkEditPart link = (PageflowLinkEditPart) iterLinks - .next(); - link.validate(); - // validateLink(link); - } - } - - } - - /** - * validate the page based on model and its's edit part. - * - * @param pagePart - - * it can be null, then the edit part will not be updated - */ - public static void validatePage(PageflowNodeEditPart pagePart) { - if (pagePart == null && pagePart.getParent() != null) { - return; - } - - String errorMessage = null; - - removeAnnotation(pagePart); - - errorMessage = PageflowValidation.getInstance().getNotifyMessage( - (PageflowPage) pagePart.getModel()); - - if (errorMessage != null) { - addAnnotation(pagePart, errorMessage); - } else { - removeAnnotation(pagePart); - } - - // validate the connections. - // Iterator iterLinks = pagePart.getSourceConnections().iterator(); - // while (iterLinks.hasNext()) { - // PageflowLinkEditPart link = (PageflowLinkEditPart) iterLinks.next(); - // - // validateLink(link); - // } - } - - /** - * validate the link based on model and its's edit part. - * - * @param linkPart - - * it can be null, then the edit part will not be updated - */ - public static void validateLink(PageflowLinkEditPart linkPart) { - if (linkPart != null && linkPart.getParent() != null) { - String errorMessage = null; - - removeAnnotation(linkPart); - - errorMessage = PageflowValidation.getInstance().isValidLink( - (PageflowLink) linkPart.getModel()); - - if (errorMessage != null) { - addAnnotation(linkPart, errorMessage); - } else { - removeAnnotation(linkPart); - } - } - } - - /** - * add a marker with IMarker.PROBLEM type, IMarker.SEVERITY_ERROR severity, - * and message. - * - * @param editPart - * @param model - * @param message - */ - private static void addAnnotation(GraphicalEditPart editPart, String message) { - if (editPart != null && editPart instanceof IAnnotationEditPart) { - Annotation annotation = new Annotation(IMarker.PROBLEM, false, - message); - ((IAnnotationEditPart) editPart).addAnnotation(annotation); - } - } - - /** - * remove a marker - * - * @param editPart - * @param model - */ - private static void removeAnnotation(GraphicalEditPart editPart) { - if (editPart != null && editPart instanceof IAnnotationEditPart) { - ((IAnnotationEditPart) editPart).removeAnnotation(); - } - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/PageflowModelManager.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/PageflowModelManager.java deleted file mode 100644 index e09795a11..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/PageflowModelManager.java +++ /dev/null @@ -1,278 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.util; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; -import org.eclipse.emf.ecore.xmi.XMLResource; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowFactory; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowPackageImpl; - -/** - * Drives the model. Acts as the model entry point, including create, load, save - * operations. - * - * @author Xiao-guang Zhang - */ -public class PageflowModelManager { - /** - * In EMF, a resource provides the way to have access to the model content. - */ - private Resource resourcePageflow = null; - - /** - * the path of current pageflow model resource provides the way to have - * access to the model content. - */ - private IPath pathPageflow = null; - - /** - * Contains the factory associated with the model. - */ - private static PageflowFactory pageflowFactory = null; - - /** - * Gives access to the top level pageflow contained in the resource. - */ - private Pageflow pageflow = null; - - /** - * resource set - */ - private ResourceSet resourceSet = null; - - /** unicode encoding UTF-8 support */ - private static HashMap defaultSaveOptions = new HashMap(); - - static { - defaultSaveOptions.put(XMLResource.OPTION_ENCODING, "UTF-8"); //$NON-NLS-1$ - } - - /** - * Uses lazy initialization. - * - * @param path - - * pageflow file name - * @return the resource containing the pageflow - */ - public Resource getResource(IPath path) { - if (resourcePageflow == null) { - pathPageflow = path; - ResourceSet resSet = getResourceSet(); - resourcePageflow = resSet.getResource(URI.createPlatformResourceURI(path - .toString()), true); - } - - return resourcePageflow; - } - - /** - * - * @return the top level pageflow model - */ - public Pageflow getModel() { - if (null == pageflow) { - EList l = resourcePageflow.getContents(); - Iterator i = l.iterator(); - while (i.hasNext()) { - Object o = i.next(); - if (o instanceof Pageflow) { - pageflow = (Pageflow) o; - } - } - } - return pageflow; - } - - /** - * Creates a resource to contain the network. The resource file does not - * exist yet. - * - * @param path - * @return - */ - private Resource createResource(IPath path) { - if (resourcePageflow == null) { - pathPageflow = path; - ResourceSet resSet = getResourceSet(); - resourcePageflow = resSet.createResource(URI.createPlatformResourceURI(path - .toString())); - } - return resourcePageflow; - } - - /** - * Returns the resource set. - * - * @param - * @return - */ - private ResourceSet getResourceSet() { - if (null == resourceSet) { - // Initialize the pageflow package, this line can not be removed. - PageflowPackageImpl.init(); - // Register the XML resource factory for the .pageflow extension - Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE; - Map regMap = reg.getExtensionToFactoryMap(); - // m.put("pageflow", new XMIResourceFactoryImpl()); - regMap.put("pageflow", new PageflowResourceFactoryImpl()); - - resourceSet = new ResourceSetImpl(); - } - - return resourceSet; - } - - /** - * Returns the factory associated with the model. Object creation are made - * through that factory. - * - * @return - pageflow factory - */ - static public PageflowFactory getFactory() { - if (pageflowFactory == null) { - // Access the factory (needed to create instances) - Map registry = EPackage.Registry.INSTANCE; - String pageflowURI = PageflowPackage.eNS_URI; - PageflowPackage pageflowPackage = (PageflowPackage) registry - .get(pageflowURI); - pageflowFactory = pageflowPackage.getPageflowFactory(); - } - return pageflowFactory; - } - - /** - * Creates a new pageflow model with begin and end nodes. - * - * @param path - - * the new pageflow file name - * @return - new pageflow model - */ - public Pageflow createPageflow(IPath path) { - createResource(path); - // Create a new pageflow model - Map registry = EPackage.Registry.INSTANCE; - String pageflowURI = PageflowPackage.eNS_URI; - PageflowPackage nPackage = (PageflowPackage) registry.get(pageflowURI); - PageflowFactory nFactory = nPackage.getPageflowFactory(); - pageflow = nFactory.createPageflow(); - - resourcePageflow.getContents().add(pageflow); - return pageflow; - } - - /** - * Loads the content of the model from the file. - * - * @param path - */ - public void load(IPath path) { - getResource(path); - } - - /** - * reloads the content of the model from the file. - * - * @param path - */ - public void reload(IPath path) { - getResource(path).unload(); - load(path); - } - - /** - * Saves the content of the model to the file. - * - * @param path - */ - public void save(final IPath path) throws IOException { - if (!pathPageflow.toString().equalsIgnoreCase(path.toString())) { - pathPageflow = path; - URI fileURI = URI.createPlatformResourceURI(path.toString()); - resourcePageflow.setURI(fileURI); - } - resourcePageflow.save(defaultSaveOptions); - } - - /** - * get the file path of current pageflow resource - * - * @return - the file path - */ - public IPath getPath() { - return pathPageflow; - } - - /** - * @param webPath - * @return found page node according the web path. - */ - public PageflowPage foundPage(String webPath) { - PageflowPage page = null; - - if (getModel() != null) { - Iterator iterNodes = getModel().getNodes().iterator(); - while (iterNodes.hasNext()) { - PageflowNode node = (PageflowNode) iterNodes.next(); - if (node instanceof PageflowPage) { - if (((PageflowPage) node).getPath().equalsIgnoreCase(webPath)) { - page = (PageflowPage) node; - break; - } - } - } - } - - return page; - } - - /** - * - * Build a path for the resource in the .metadata directory given the path - * of the model resource. For example, given a model resource path of - * \test\folder\filename.ext the resulting Pageflow path name will be - * \test\.metadata\folder\filename.pageflow - * - * @param pathFacesConfig - - * faces-config file path. - * - * @return the ipath - */ - public static IPath makePageflowPath(IPath pathFacesConfig) { - IPath pageflowPath; - String[] segs = pathFacesConfig.removeFileExtension().segments(); - pageflowPath = new Path(segs[0]).makeAbsolute(); - pageflowPath = pageflowPath.append(".metadata"); - for (int i = 1; i < segs.length; i++) { - pageflowPath = pageflowPath.append(segs[i]); - } - // pageflowPath.removeFileExtension(); - pageflowPath = pageflowPath.addFileExtension("pageflow"); - return pageflowPath; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/PageflowResourceFactory.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/PageflowResourceFactory.java deleted file mode 100644 index 305f7b518..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/PageflowResourceFactory.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.util; - -import org.eclipse.core.resources.IResource; -import org.eclipse.gef.requests.CreationFactory; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowFactory; -import org.eclipse.jst.jsf.facesconfig.ui.util.WebrootUtil; - -/** - * - * This is the Page Flow Resource Factory for resource drag and drop - * - * @author Xiao-guang Zhang - */ -public class PageflowResourceFactory implements CreationFactory { - /** resource */ - private IResource resource; - - public PageflowResourceFactory(IResource resource) { - this.resource = resource; - } - - /* - * (non-javadoc) - * - * @see Factory#getNewObject() - */ - public Object getNewObject() { - if (null == resource) { - return null; - } - - String strWebPath = WebrootUtil.getWebPath(resource.getFullPath()); - if (strWebPath.length() > 0) { - PageflowFactory factory = PageflowModelManager.getFactory(); - Object result = factory.createPFPage(); - PageflowPage page = (PageflowPage) result; - page.setPath(strWebPath); - page.setName(WebrootUtil.getPageNameFromWebPath(strWebPath)); - return page; - } - - EditorPlugin - .getAlerts() - .error( - "Pageflow.Error.DNDResourceTitle", - EditorPlugin - .getResourceString("Pageflow.Error.InvalidResource") - + resource.getName()); - - return null; - } - - /* - * (non-javadoc) - * - * @see Factory#getObjectType() - */ - public Object getObjectType() { - return resource; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/PageflowResourceFactoryImpl.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/PageflowResourceFactoryImpl.java deleted file mode 100644 index 1181474f8..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/PageflowResourceFactoryImpl.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.util; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.xmi.impl.XMLResourceFactoryImpl; - -/** - * The <b>Resource Factory</b> associated with the package. - * - * @author Xiao-guang Zhang - */ -public class PageflowResourceFactoryImpl extends XMLResourceFactoryImpl { - /** - * Creates an instance of the resource factory. - */ - public PageflowResourceFactoryImpl() { - super(); - } - - /** - * Creates an instance of the resource. - */ - public Resource createResource(URI uri) { - Resource result = new PageflowResourceImpl(uri); - return result; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/PageflowResourceImpl.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/PageflowResourceImpl.java deleted file mode 100644 index 07e13ee12..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/PageflowResourceImpl.java +++ /dev/null @@ -1,36 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.util; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl; - -/** - * - * The <b>Resource </b> associated with the package. - * - * @author Xiao-guang Zhang - */ -public class PageflowResourceImpl extends XMLResourceImpl { - /** - * Creates an instance of the resource. <!-- begin-user-doc --> <!-- - * end-user-doc --> - * - * @param uri - * the URI of the new resource. - * @generated - */ - public PageflowResourceImpl(URI uri) { - super(uri); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/PageflowSwitch.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/PageflowSwitch.java deleted file mode 100644 index 944ee4460..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/PageflowSwitch.java +++ /dev/null @@ -1,249 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.util; - -import java.util.List; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLinkBendpoint; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowElement; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage; - -/** - * <!-- begin-user-doc --> The <b>Switch</b> for the model's inheritance - * hierarchy. It supports the call {@link #doSwitch(EObject)} to invoke - * the <code>caseXXX</code> method for each class of the model, starting with - * the actual class of the object and proceeding up the inheritance hierarchy - * until a non-null result is returned, which is the result of the switch. <!-- - * end-user-doc --> - * - * @see org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPackage - * @generated - */ -public class PageflowSwitch { - /** - * The cached model package <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated - */ - protected static PageflowPackage modelPackage; - - /** - * Creates an instance of the switch. <!-- begin-user-doc --> <!-- - * end-user-doc --> - * - * @generated - */ - public PageflowSwitch() { - if (modelPackage == null) { - modelPackage = PageflowPackage.eINSTANCE; - } - } - - /** - * Calls <code>caseXXX</code> for each class of the model until one - * returns a non null result; it yields that result. <!-- begin-user-doc --> - * <!-- end-user-doc --> - * - * @return the first non-null result returned by a <code>caseXXX</code> - * call. - * @generated - */ - public Object doSwitch(EObject theEObject) { - return doSwitch(theEObject.eClass(), theEObject); - } - - /** - * Calls <code>caseXXX</code> for each class of the model until one - * returns a non null result; it yields that result. <!-- begin-user-doc --> - * <!-- end-user-doc --> - * - * @return the first non-null result returned by a <code>caseXXX</code> - * call. - * @generated - */ - protected Object doSwitch(EClass theEClass, EObject theEObject) { - if (theEClass.eContainer() == modelPackage) { - return doSwitch(theEClass.getClassifierID(), theEObject); - } - List eSuperTypes = theEClass.getESuperTypes(); - return eSuperTypes.isEmpty() ? defaultCase(theEObject) : doSwitch( - (EClass) eSuperTypes.get(0), theEObject); - } - - /** - * Calls <code>caseXXX</code> for each class of the model until one - * returns a non null result; it yields that result. <!-- begin-user-doc --> - * <!-- end-user-doc --> - * - * @return the first non-null result returned by a <code>caseXXX</code> - * call. - * @generated - */ - protected Object doSwitch(int classifierID, EObject theEObject) { - switch (classifierID) { - case PageflowPackage.PAGEFLOW: { - Pageflow pageflow = (Pageflow) theEObject; - Object result = casePageflow(pageflow); - if (result == null) - result = casePageflowElement(pageflow); - if (result == null) - result = defaultCase(theEObject); - return result; - } - case PageflowPackage.PF_LINK: { - PageflowLink pfLink = (PageflowLink) theEObject; - Object result = casePFLink(pfLink); - if (result == null) - result = casePageflowElement(pfLink); - if (result == null) - result = defaultCase(theEObject); - return result; - } - - case PageflowPackage.PF_PAGE: { - PageflowPage pfPage = (PageflowPage) theEObject; - Object result = casePFPage(pfPage); - if (result == null) - result = casePageflowNode(pfPage); - if (result == null) - result = casePageflowElement(pfPage); - if (result == null) - result = defaultCase(theEObject); - return result; - } - - case PageflowPackage.PF_LINK_BENDPOINT: { - PageflowLinkBendpoint pfLinkBendpoint = (PageflowLinkBendpoint) theEObject; - Object result = casePFLinkBendpoint(pfLinkBendpoint); - if (result == null) - result = defaultCase(theEObject); - return result; - } - default: - return defaultCase(theEObject); - } - } - - /** - * Returns the result of interpretting the object as an instance of '<em>Pageflow</em>'. - * <!-- begin-user-doc --> This implementation returns null; returning a - * non-null result will terminate the switch. <!-- end-user-doc --> - * - * @param object - * the target of the switch. - * @return the result of interpretting the object as an instance of '<em>Pageflow</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public Object casePageflow(Pageflow object) { - return null; - } - - /** - * Returns the result of interpretting the object as an instance of '<em>Node</em>'. - * <!-- begin-user-doc --> This implementation returns null; returning a - * non-null result will terminate the switch. <!-- end-user-doc --> - * - * @param object - * the target of the switch. - * @return the result of interpretting the object as an instance of '<em>Node</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public Object casePageflowNode(PageflowNode object) { - return null; - } - - /** - * Returns the result of interpretting the object as an instance of '<em>PF Link</em>'. - * <!-- begin-user-doc --> This implementation returns null; returning a - * non-null result will terminate the switch. <!-- end-user-doc --> - * - * @param object - * the target of the switch. - * @return the result of interpretting the object as an instance of '<em>PF Link</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public Object casePFLink(PageflowLink object) { - return null; - } - - /** - * Returns the result of interpretting the object as an instance of '<em>Element</em>'. - * <!-- begin-user-doc --> This implementation returns null; returning a - * non-null result will terminate the switch. <!-- end-user-doc --> - * - * @param object - * the target of the switch. - * @return the result of interpretting the object as an instance of '<em>Element</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public Object casePageflowElement(PageflowElement object) { - return null; - } - - /** - * Returns the result of interpretting the object as an instance of '<em>PF Page</em>'. - * <!-- begin-user-doc --> This implementation returns null; returning a - * non-null result will terminate the switch. <!-- end-user-doc --> - * - * @param object - * the target of the switch. - * @return the result of interpretting the object as an instance of '<em>PF Page</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public Object casePFPage(PageflowPage object) { - return null; - } - - /** - * Returns the result of interpretting the object as an instance of '<em>PF Link Bendpoint</em>'. - * <!-- begin-user-doc --> This implementation returns null; returning a - * non-null result will terminate the switch. <!-- end-user-doc --> - * - * @param object - * the target of the switch. - * @return the result of interpretting the object as an instance of '<em>PF Link Bendpoint</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) - * @generated - */ - public Object casePFLinkBendpoint(PageflowLinkBendpoint object) { - return null; - } - - /** - * Returns the result of interpretting the object as an instance of '<em>EObject</em>'. - * <!-- begin-user-doc --> This implementation returns null; returning a - * non-null result will terminate the switch, but this is the last case - * anyway. <!-- end-user-doc --> - * - * @param object - * the target of the switch. - * @return the result of interpretting the object as an instance of '<em>EObject</em>'. - * @see #doSwitch(org.eclipse.emf.ecore.EObject) - * @generated - */ - public Object defaultCase(EObject object) { - return null; - } - -} -// PageflowSwitch diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/PageflowTransform.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/PageflowTransform.java deleted file mode 100644 index 6a1011a78..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/PageflowTransform.java +++ /dev/null @@ -1,163 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.util; - -import org.eclipse.jst.jsf.facesconfig.emf.DescriptionType; -import org.eclipse.jst.jsf.facesconfig.emf.DisplayNameType; -import org.eclipse.jst.jsf.facesconfig.emf.IconType; -import org.eclipse.jst.jsf.facesconfig.emf.NavigationCaseType; -import org.eclipse.jst.jsf.facesconfig.emf.NavigationRuleType; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; - -/** - * The tranform between pageflow and navigation rules in faces-config file. - * - * @author Xiao-guang Zhang - */ -public class PageflowTransform { - - /** The shared singleton instance. */ - private static PageflowTransform transform; - - private PageflowTransform() { - // private contructor - } - - /** - * Returns the shared singleton instance. - */ - public static PageflowTransform getInstance() { - if (transform == null) { - transform = new PageflowTransform(); - } - return transform; - } - - /** - * Update source PFPage with Faces-config model. - * - * @param sourcePage - * @param navigationRuleFC - * @author sfshi - */ - public void updatePageflowSourcePage(PageflowPage sourcePage, - NavigationRuleType navigationRuleFC) { - // set the descriiption of link - if (navigationRuleFC.getDescription() != null - && navigationRuleFC.getDescription().size() > 0) { - String description = ((DescriptionType) navigationRuleFC - .getDescription().get(0)).getTextContent(); - sourcePage.setComment(description); - } - // set the display-name of link - if (navigationRuleFC.getDisplayName() != null - && navigationRuleFC.getDisplayName().size() > 0) { - String displayName = ((DisplayNameType) navigationRuleFC - .getDisplayName().get(0)).getTextContent(); - sourcePage.setName(displayName); - } - - // Set the icon of link - if (navigationRuleFC.getIcon() != null - && navigationRuleFC.getIcon().size() > 0) { - boolean largeUpdated = false; - boolean smallUpdated = false; - for (int i = 0; i < navigationRuleFC.getIcon().size(); i++) { - IconType icon = (IconType) navigationRuleFC.getIcon().get(i); - if (!largeUpdated && icon.getLargeIcon() != null) { - sourcePage.setLargeicon(icon.getLargeIcon() - .getTextContent()); - largeUpdated = true; - } - - if (!smallUpdated && icon.getSmallIcon() != null) { - sourcePage.setSmallicon(icon.getSmallIcon() - .getTextContent()); - smallUpdated = true; - } - if (largeUpdated && smallUpdated) { - return; - } - } - } - } - - /** - * Update target PFPage with Faces-config model. - * - * @param targetPage - * @param navigationCaseFC - * @author sfshi - */ - public void updatePageflowTargetPage(PageflowPage targetPage, - NavigationCaseType navigationCaseFC) { - // set the descriiption of link - if (navigationCaseFC.getDescription() != null - && navigationCaseFC.getDescription().size() > 0) { - String description = ((DescriptionType) navigationCaseFC - .getDescription().get(0)).getTextContent(); - targetPage.setComment(description); - } - // set the display-name of link - if (navigationCaseFC.getDisplayName() != null - && navigationCaseFC.getDisplayName().size() > 0) { - String displayName = ((DisplayNameType) navigationCaseFC - .getDisplayName().get(0)).getTextContent(); - targetPage.setName(displayName); - } - - // Set the icon of link - if (navigationCaseFC.getIcon() != null - && navigationCaseFC.getIcon().size() > 0) { - boolean largeUpdated = false; - boolean smallUpdated = false; - for (int i = 0; i < navigationCaseFC.getIcon().size(); i++) { - IconType icon = (IconType) navigationCaseFC.getIcon().get(0); - if (!largeUpdated && icon.getLargeIcon() != null) { - targetPage.setLargeicon(icon.getLargeIcon() - .getTextContent()); - largeUpdated = true; - } - - if (!smallUpdated && icon.getSmallIcon() != null) { - targetPage.setSmallicon(icon.getSmallIcon() - .getTextContent()); - smallUpdated = true; - } - if (largeUpdated && smallUpdated) { - return; - } - } - } - } - - /** - * update the pageflow model 's information, including pageflow's name, - * description and related config file - * - * @param newPageflow - * @param oldPageflow - */ - public static void updatePageflowModelInfo(Pageflow newPageflow, - Pageflow oldPageflow) { - if (newPageflow == null || oldPageflow == null) { - return; - } - newPageflow.setName(oldPageflow.getName()); - newPageflow.setComment(oldPageflow.getComment()); - newPageflow.setConfigfile(oldPageflow.getConfigfile()); - - } -} -// PageflowTransform diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/PageflowValidation.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/PageflowValidation.java deleted file mode 100644 index 42e49e776..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/pageflow/util/PageflowValidation.java +++ /dev/null @@ -1,285 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.pageflow.util; - -import java.util.Iterator; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.Path; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowMessages; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowLink; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowNode; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.PageflowPage; -import org.eclipse.jst.jsf.facesconfig.ui.util.WebrootUtil; -import org.eclipse.osgi.util.NLS; - -/** - * Pageflow's validation functions - * - * @author Xiao-guang Zhang - */ -public class PageflowValidation { - /** PageflowValidation singleton instance */ - private static PageflowValidation instance; - - /** constructor */ - private PageflowValidation() { - // no external instantiation - } - - /** - * get the singleton instance of pageflow validation - * - * @return the singleton instance of pageflow validation - */ - public static PageflowValidation getInstance() { - if (instance == null) { - instance = new PageflowValidation(); - } - return instance; - } - - /** - * check whether the source and target pageflow node are allowed to create a - * new link NOT allowed source and target: 1. target node is Begin or source - * node is End 2. both of source and target node are Action. 3. double - * connection from the same source to target - * - * @param source - - * source pageflow node - * @param target - - * target pageflow node - * @return - is valid link or not. - * - */ - public boolean isValidLinkForCreation(PageflowNode source, - PageflowNode target) { - // Source and target must be pointing to some real pageflow node - if (source == null || target == null) { - return false; - } - return true; - } - - /** - * determine the pflink is valid or not for property souce. in our model, - * there are five types of invalid pflinke for property source. 1. link - * between page and action 2. the source of link is Begin or End node 3. the - * target of link is Begin or End node. - * - * @return - valid link or not. - * - */ - public boolean isValidLinkForProperty(PageflowLink link) { - return true; - } - - /** - * determine the pflink is valid or not for face-config rule in our model, - * there are four types of invalid pflinke. 1. the source of link is Begin - * or End node 2. the target of link is Begin or End node. - * - * @return - valid link or not. - * - */ - public boolean isValidLinkForNavigationRule(PageflowLink link) { - return true; - } - - /** - * determine the pflink is valid or not for face-config rule in our model, - * there are four types of invalid pflinke. - * - * @return - valid link or not. - * - */ - public String isValidLink(PageflowLink link) { - String errorMessage = null; - // action-page style - // TODO: it should guarantee that outcome should be defined in the - // managed bean's method. - - if (link.getSource() instanceof PageflowPage - && link.getTarget() instanceof PageflowPage) { - String outcome = link.getOutcome(); - if (outcome != null && outcome.length() >= 0) { - // if (isValidServiceOutcome(outcome)) - // { - // return errorMessage; - // } - String webPath = ((PageflowPage) link.getSource()).getPath(); - if (webPath != null) { - String projectPath = WebrootUtil.getProjectPath(link, - webPath); - - Path resourcePath = new Path(projectPath); - IWorkspaceRoot workspaceRoot = ResourcesPlugin - .getWorkspace().getRoot(); - final IResource resource = workspaceRoot - .findMember(resourcePath); - - if (resource == null || !resource.exists()) { - // Pageflow.Validation.NotExistedSourcePage = The source - // page {0} is not existed. - errorMessage = NLS - .bind( - PageflowMessages.Pageflow_Validation_UndefinedOutcome, - outcome, webPath); - } - } else { - // Pageflow.Validation.MissingSourcePage = The source page - // should be specified. - errorMessage = PageflowMessages.Pageflow_Validation_MissingSourcePage; - } - } - } - return errorMessage; - } - - /** - * Check whether the page is already existed in the pageflow. - * - * @param pageflow - * @param page - * @return true if page exists (?) - */ - public boolean isExistedPage(Pageflow pageflow, PageflowPage page) { - if (pageflow == null || page == null || page.getPath() == null) { - return false; - } - - return isExistedPage(pageflow, page.getPath()); - } - - /** - * Check whether the page is already existed in the pageflow. - * - * @param pageflow - * @param pagePath - * @return true if pageflow's path is equal to pagePath - */ - public boolean isExistedPage(Pageflow pageflow, String pagePath) { - if (pageflow == null || pagePath == null) { - return false; - } - - Iterator iter = pageflow.getNodes().iterator(); - - while (iter.hasNext()) { - PageflowNode existedNode = (PageflowNode) iter.next(); - - if (existedNode instanceof PageflowPage) { - if (((PageflowPage) existedNode).getPath() != null - && ((PageflowPage) existedNode).getPath() - .equalsIgnoreCase(pagePath)) { - return true; - } - } - } - - return false; - } - - /** - * Check whether the page is valid or not validate page is : 1. if the page - * is general jsp page, it should physically existed. 2. if the page is in - * the form of /foldername/* (it contains the folder), the folder should be - * existed. - * - * @param page - * @return the notify message for page - */ - public String getNotifyMessage(PageflowPage page) { - String errorMessage = null; - IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); - String pagePath = page.getPath(); - - // Check the path is empty or not - if (pagePath != null && pagePath.length() > 0) { - String resourceName = WebrootUtil.getProjectPath(page, pagePath); - Path resourcePath = new Path(resourceName); - - final IResource resource = workspaceRoot.findMember(resourcePath); - - if (resource != null && resource.exists()) { - // This page is related with jsp file - if (resourcePath.getFileExtension() != null) { - if (!WebrootUtil.isValidWebFile(resourcePath)) { - // Pageflow.Validation.InvalidWebPage = the file {0} is - // not valid web file. - errorMessage = NLS - .bind( - PageflowMessages.Pageflow_Validation_InvalidWebPage, - pagePath); - } - } - } else { - // Pageflow.Validation.NotExitedWebPage = the web page {0} is - // not existed. - errorMessage = NLS.bind( - PageflowMessages.Pageflow_Validation_NotExitedWebPage, - pagePath); - } - } else { - // Pageflow.Validation.MissingWebPage = the web page's path should - // be specified. - errorMessage = PageflowMessages.Pageflow_Validation_MissingWebPage; - } - return errorMessage; - } - - /** - * check that the action is valid EL or not, - * - * @param actionEL - - * action string, it should be in the form of #{...} - * @return - True or False - */ - public static boolean isValidActionEL(String actionEL) { - if (actionEL != null && actionEL.length() > 3) { - // action is defined in JSF expression language, e.g, - // #{beanname.methodname} - if (actionEL.substring(0, 2).equalsIgnoreCase("#{")//$NON-NLS-1$ - && actionEL.substring(actionEL.length() - 1, - actionEL.length()).equalsIgnoreCase("}"))//$NON-NLS-1$ - { - // Check the bean is existed or not. - return true; - } - - } - return false; - } - - /** - * get the managed bean from action's expression, e.g., beanName.methodName. - * The return will be beanName. - * - * @param actionEL - * @return the managed bean name - */ - public static String getManagedBeanforAction(String actionEL) { - String managedBeanName = null; - if (isValidActionEL(actionEL)) { - actionEL = actionEL.substring(2, actionEL.length() - 1); - String[] actionParts = actionEL.split("[.]"); - managedBeanName = actionParts[0];//$NON-NLS-1$ - } - - return managedBeanName; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/BaseFigureDecorator.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/BaseFigureDecorator.java deleted file mode 100644 index 301d6fe25..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/BaseFigureDecorator.java +++ /dev/null @@ -1 +0,0 @@ -/*******************************************************************************
* Copyright (c) 2004, 2006 Sybase, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sybase, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.jst.jsf.facesconfig.ui.preference;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.RotatableDecoration;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.draw2d.geometry.Transform;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
public class BaseFigureDecorator extends Label implements RotatableDecoration
{
public static int DEFAULT_DECORATOR_POSITION = PositionConstants.SOUTH_WEST;
private Point location = new Point();
private Transform transform = new Transform();
private int position;
public BaseFigureDecorator(Image image)
{
this.position = DEFAULT_DECORATOR_POSITION;
setIcon(image);
setSize(getPreferredSize());
}
public BaseFigureDecorator(Image image, String tooltip)
{
this.position = DEFAULT_DECORATOR_POSITION;
setIcon(image);
setSize(getPreferredSize());
setToolTip(new Label(tooltip));
}
public BaseFigureDecorator(Image image, String tooltip, int position)
{
this.position = position;
setIcon(image);
setSize(getPreferredSize());
setToolTip(new Label(tooltip));
}
public Font getFont()
{
Font localFont = getLocalFont();
if (localFont == null)
{
localFont = JFaceResources.getFontRegistry().get(
JFaceResources.DEFAULT_FONT);
// TODO: it's not clear that setFont is correct to call
// here since this does a revalidate if the font changes
// whereas the deprecated assignment to font that it replaces
// does not
setFont(localFont);
}
return localFont;
}
/**
*
* @return Returns the position.
*
*/
public int getPosition()
{
return position;
}
/**
*
* @param position
*
* The position to set.
*
*/
public void setPosition(int position)
{
this.position = position;
}
public void setToolTipText(String tooltip)
{
super.setToolTip(new Label(tooltip));
}
public String getToolTipText()
{
Label label = (Label) super.getToolTip();
return label.getText();
}
/**
*
* Sets the location of this PolygonDecoration.
*
*
*
* @param p
*
* the new location
*
*/
public void setLocation(Point p)
{
bounds = null;
location.setLocation(p);
transform.setTranslation(p.x, p.y);
}
public Rectangle getBounds()
{
if (bounds == null)
{
if (prefSize == null)
{
getPreferredSize();
}
int w = prefSize.width;
int h = prefSize.height;
Point p = location; // transform.getTransformed(new Point(w/2,h/2));
bounds = new Rectangle(p.x - w / 2, p.y - h / 2, w, h).getExpanded(
w, h);
}
return bounds;
}
/**
*
* @see org.eclipse.draw2d.Figure#useLocalCoordinates()
*
*/
protected boolean useLocalCoordinates()
{
return false;
}
public void setScale(double x, double y)
{
// TODO: figure out how to scale images
bounds = null;
transform.setScale(x, y);
}
/**
*
* Sets the rotation of this decoration so that the decoration points toward
* the
*
* given reference point.
*
* @param ref
* the reference point
*
* @see org.eclipse.draw2d.RotatableDecoration#setReferencePoint(org.eclipse.draw2d.geometry.Point)
*
*/
public void setReferencePoint(Point ref)
{
// TODO: figure out how to rotate images
bounds = null;
Point pt = Point.SINGLETON;
pt.setLocation(ref);
pt.negate().translate(location);
setRotation(Math.atan2(pt.y, pt.x));
}
/**
*
* Sets the angle by which rotation is to be done on the PolygonDecoration.
*
*
*
* @param angle
* Angle of rotation
*
* @since 2.0
*
*/
public void setRotation(double angle)
{
bounds = null;
// transform.setRotation(angle);
}
}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/BaseNodeFigure.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/BaseNodeFigure.java deleted file mode 100644 index 2dbcbd853..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/BaseNodeFigure.java +++ /dev/null @@ -1,923 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.preference; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.List; -import java.util.Vector; - -import org.eclipse.draw2d.ConnectionAnchor; -import org.eclipse.draw2d.Figure; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Layer; -import org.eclipse.draw2d.LayoutManager; -import org.eclipse.draw2d.PolylineConnection; -import org.eclipse.draw2d.PositionConstants; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Insets; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.swt.graphics.Image; - -/** - * The <code>BaseNodeFigure</code> class is the base class for all the figures - * representing DiagramNodes, ie those that can have ports with maxConnections - * to other nodes. - * - * Assumes that all NodeFigures have some number of input and output ports - * - * @author ddean - * - */ -public class BaseNodeFigure extends Figure implements IBaseFigure { - protected IBaseFigure baseFigure; - - protected boolean anchorsVisible = true; - - protected Hashtable connectionAnchors = new Hashtable(7); - - protected Vector inputConnectionAnchors = new Vector(2, 2); - - protected Vector outputConnectionAnchors = new Vector(2, 2); - - protected Vector topConnectionAnchors = new Vector(); - - protected Vector bottomConnectionAnchors = new Vector(); - - protected Vector leftConnectionAnchors = new Vector(); - - protected Vector rightConnectionAnchors = new Vector(); - - public BaseNodeFigure(IBaseFigure figure) { - setBaseFigure(figure); - ObserveVisibleXYLayout layout = new ObserveVisibleXYLayout(); - layout.setObserveVisibility(true); - setLayoutManager(layout); - } - - public void setBaseFigure(IBaseFigure figure) { - setBaseFigure(figure, new Rectangle(0, 0, -1, -1)); - } - - public void setHighlight(boolean flag) { - if (baseFigure != null) { - moveToTop(this, baseFigure); - baseFigure.setHighlight(flag); - } - } - - public void setBaseFigure(IBaseFigure figure, Rectangle constraint) { - if (!getChildren().contains(figure)) { - if (getChildren().contains(baseFigure)) - remove(baseFigure); - - baseFigure = figure; - if (!getChildren().contains(baseFigure)) { - // CR389070: Figures are abbreviating rule figures names and - // making them unreadable - if (getParent() != null - && getParent().getLayoutManager() != null) { - Rectangle r = getBounds().getCopy(); - r.width = -1; - r.height = -1; - getParent().getLayoutManager().setConstraint(this, r); - } - // CR389495: Working with nested complex activities causes in - // the BP editor causes lockup - // ensure that constraints are set on figure before add() - this - // will cause a layout() - this.add(baseFigure, constraint, 0); - } - } - } - - public IBaseFigure getBaseFigure() { - return baseFigure; - } - - /*************************************************************************** - * Input/Output Ports - **************************************************************************/ - - /** - * Add an input port and its anchor - * - * @param portName - * unique name to refer to the port - */ - public void addInput(String portName) { - InputPortFigure inputPort = new InputPortFigure(); - add(inputPort); - inputPort.setToolTipText(portName); - - PortConnectionAnchor anchor = new PortConnectionAnchor(inputPort); - getTargetConnectionAnchors().add(anchor); - connectionAnchors.put(portName, anchor); - } - - /** - * Add an output port and its anchor - * - * @param portName - * unique name to refer to the port - */ - public PortConnectionAnchor addOutput(String portName) { - OutputPortFigure outputPort = new OutputPortFigure(); - add(outputPort); - outputPort.setToolTipText(portName); - - PortConnectionAnchor anchor = new PortConnectionAnchor(outputPort); - getSourceConnectionAnchors().add(anchor); - connectionAnchors.put(portName, anchor); - return anchor; - } - - /** - * Searches for and returns the anchor on this figure that is closest to the - * reference point <code>p</code> - * - * @param p - * the reference point - * @return the anchor on this figure that is closest to <code>p</code> - */ - public ConnectionAnchor connectionAnchorAt(Point p) { - ConnectionAnchor closest = null; - long min = Long.MAX_VALUE; - - Enumeration e = getSourceConnectionAnchors().elements(); - while (e.hasMoreElements()) { - ConnectionAnchor c = (ConnectionAnchor) e.nextElement(); - Point p2 = c.getLocation(null); - long d = p.getDistance2(p2); - if (d < min) { - min = d; - closest = c; - } - } - e = getTargetConnectionAnchors().elements(); - while (e.hasMoreElements()) { - ConnectionAnchor c = (ConnectionAnchor) e.nextElement(); - Point p2 = c.getLocation(null); - long d = p.getDistance2(p2); - if (d < min) { - min = d; - closest = c; - } - } - return closest; - } - - /** - * returns an anchor given its name - * - * @param portName - * name of the anchor - * @return the anchor with the name <code>portName</code> - */ - public ConnectionAnchor getConnectionAnchor(String portName) { - return (ConnectionAnchor) connectionAnchors.get(portName); - } - - /** - * returns the name of the specified anchor - * - * @param c - * the anchor whose name is requested - * @return the name of the specifed anchor - */ - public String getConnectionAnchorName(ConnectionAnchor c) { - Enumeration enumer = connectionAnchors.keys(); - String key; - while (enumer.hasMoreElements()) { - key = (String) enumer.nextElement(); - if (connectionAnchors.get(key).equals(c)) - return key; - } - return null; - } - - /** - * returns the source connection anchor that is closest to the reference - * point - * - * @param p - * the reference point - * @return the closest connection anchor to <code>p</code> - */ - public ConnectionAnchor getSourceConnectionAnchorAt(Point p) { - ConnectionAnchor closest = null; - long min = Long.MAX_VALUE; - - Enumeration e = getSourceConnectionAnchors().elements(); - while (e.hasMoreElements()) { - ConnectionAnchor c = (ConnectionAnchor) e.nextElement(); - Point p2 = c.getLocation(null); - long d = p.getDistance2(p2); - if (d < min) { - min = d; - closest = c; - } - } - return closest; - } - - /** - * returns all the source connection anchors on this node figure - * - * @return a vector of all the source connection anchors for this figure - */ - public Vector getSourceConnectionAnchors() { - return outputConnectionAnchors; - } - - /** - * returns the target connection anchor that is closest to the reference - * point - * - * @param p - * the reference point - * @return the closest target connection anchor to <code>p</code> - */ - public ConnectionAnchor getTargetConnectionAnchorAt(Point p) { - ConnectionAnchor closest = null; - long min = Long.MAX_VALUE; - - Enumeration e = getTargetConnectionAnchors().elements(); - while (e.hasMoreElements()) { - ConnectionAnchor c = (ConnectionAnchor) e.nextElement(); - Point p2 = c.getLocation(null); - long d = p.getDistance2(p2); - if (d < min) { - min = d; - closest = c; - } - } - return closest; - } - - /** - * returns all the target connection anchors on this node figure - * - * @return a vector of all the target connection anchors for this figure - */ - public Vector getTargetConnectionAnchors() { - return inputConnectionAnchors; - } - - /** - * Returns the name of the specified anchor - * - * @param anchor - * the connectio anchor whose name is requested - * @return the anchor's name - */ - public String getNameForAnchor(ConnectionAnchor anchor) { - if (anchor != null) { - Iterator it = connectionAnchors.keySet().iterator(); - String name; - - while (it.hasNext()) { - name = (String) it.next(); - - if (anchor.equals(connectionAnchors.get(name))) { - return name; - } - } - } - return null; - } - - public void setAnchorsVisible(boolean visible) { - if (anchorsVisible != visible) { - anchorsVisible = visible; - //ConnectionAnchor port; - List all = new ArrayList(); - all.addAll(getTargetConnectionAnchors()); - all.addAll(getSourceConnectionAnchors()); - Iterator it = all.iterator(); - while (it.hasNext()) { - IFigure fig = ((ConnectionAnchor) it.next()).getOwner(); - fig.setVisible(visible); - } - validate(); - } - } - - /* - * Determine which side of the figure to place each anchor based on the - * relative position (north, south, east or west) of the connection line's - * opposite anchor. If the anchor is not connected to anything else, the - * default is to place target (input) anchors on the left and source - * (output) anchors on the right. - */ - protected void determineAnchorPositions() { - Iterator it; - topConnectionAnchors.clear(); - bottomConnectionAnchors.clear(); - leftConnectionAnchors.clear(); - rightConnectionAnchors.clear(); - - if (anchorsVisible) { - //final Dimension size = baseFigure.getPreferredSize(); - PortConnectionAnchor port; - - // start with outputs - it = getSourceConnectionAnchors().iterator(); - while (it.hasNext()) { - port = (PortConnectionAnchor) it.next(); - // CR386077: SplitActivity True and False outputs switch - // positions based on their targets - int direction = port.getOrientation(); - if (direction == PositionConstants.NONE) { - Point loc = port.getOwner().getParent().getBounds() - .getLocation(); - // loc.x += size.width/2; - // loc.y += size.height/2; - Iterator itc = port.getConnections().iterator(); - if (itc.hasNext()) { - while (itc.hasNext()) { - PolylineConnection conn = (PolylineConnection) itc - .next(); - ConnectionAnchor otherPort; - if (port == conn.getSourceAnchor()) - otherPort = conn.getTargetAnchor(); - else - otherPort = conn.getSourceAnchor(); - if (otherPort.getOwner() == null) - continue; - Point otherLoc = otherPort.getOwner().getParent() - .getBounds().getLocation(); - // Dimension otherSize = - // ((BaseNodeFigure)otherPort.getOwner().getParent()).getBaseFigure().getPreferredSize(); - // otherLoc.x += otherSize.width/2; - // otherLoc.y += otherSize.height/2; - direction = loc.getPosition(otherLoc); - if (direction == PositionConstants.NORTH) - topConnectionAnchors.add(port); - else if (direction == PositionConstants.SOUTH) - bottomConnectionAnchors.add(port); - else if (direction == PositionConstants.WEST) - leftConnectionAnchors.add(port); - else - rightConnectionAnchors.add(port); - ((PortFigure) port.getOwner()) - .setOrientation(direction); - break; // currently, only the first connection is - // considered - } - } else { - rightConnectionAnchors.add(port); - ((PortFigure) port.getOwner()) - .setOrientation(PositionConstants.EAST); - } - } else { - // CR386077: SplitActivity True and False outputs switch - // positions based on their targets - if (direction == PositionConstants.NORTH) - topConnectionAnchors.add(port); - else if (direction == PositionConstants.SOUTH) - bottomConnectionAnchors.add(port); - else if (direction == PositionConstants.WEST) - leftConnectionAnchors.add(port); - else - rightConnectionAnchors.add(port); - } - } - it = getTargetConnectionAnchors().iterator(); - while (it.hasNext()) { - port = (PortConnectionAnchor) it.next(); - // CR386077: SplitActivity True and False outputs switch - // positions based on their targets - int direction = port.getOrientation(); - if (direction == PositionConstants.NONE) { - Point loc = port.getOwner().getParent().getBounds() - .getLocation(); - // loc.x += size.width/2; - // loc.y += size.height/2; - Iterator itc = port.getConnections().iterator(); - if (itc.hasNext()) { - while (itc.hasNext()) { - PolylineConnection conn = (PolylineConnection) itc - .next(); - ConnectionAnchor otherPort; - if (port == conn.getSourceAnchor()) - otherPort = conn.getTargetAnchor(); - else - otherPort = conn.getSourceAnchor(); - if (otherPort.getOwner() == null) - continue; - Point otherLoc = otherPort.getOwner().getParent() - .getBounds().getLocation(); - // Dimension otherSize = - // ((BaseNodeFigure)otherPort.getOwner().getParent()).getBaseFigure().getPreferredSize(); - // otherLoc.x += otherSize.width/2; - // otherLoc.y += otherSize.height/2; - direction = loc.getPosition(otherLoc); - if (direction == PositionConstants.NORTH) - topConnectionAnchors.add(port); - else if (direction == PositionConstants.SOUTH) - bottomConnectionAnchors.add(port); - else if (direction == PositionConstants.EAST) - rightConnectionAnchors.add(port); - else - leftConnectionAnchors.add(port); - ((PortFigure) port.getOwner()) - .setOrientation(direction); - break; // currently, only the first connection is - // considered - } - } else { - leftConnectionAnchors.add(port); - ((PortFigure) port.getOwner()) - .setOrientation(PositionConstants.WEST); - } - } else { - // CR386077: SplitActivity True and False outputs switch - // positions based on their targets - if (direction == PositionConstants.NORTH) - topConnectionAnchors.add(port); - else if (direction == PositionConstants.SOUTH) - bottomConnectionAnchors.add(port); - else if (direction == PositionConstants.EAST) - rightConnectionAnchors.add(port); - else - leftConnectionAnchors.add(port); - } - } - - Comparator comparePorts = new Comparator() { - public int compare(Object arg0, Object arg1) { - PortConnectionAnchor port0 = (PortConnectionAnchor) arg0; - if (port0.getConnections().size() < 1) - return 0; - PortConnectionAnchor port1 = (PortConnectionAnchor) arg1; - if (port1.getConnections().size() < 1) - return 0; - // CR386077: SplitActivity True and False outputs switch - // positions based on their targets - if (port0.getOrientation() != PositionConstants.NONE) - return 0; - if (port1.getOrientation() != PositionConstants.NONE) - return 0; - - PolylineConnection conn0 = (PolylineConnection) port0 - .getConnections().get(0); - ConnectionAnchor otherPort0; - if (port0 == conn0.getSourceAnchor()) - otherPort0 = conn0.getTargetAnchor(); - else - otherPort0 = conn0.getSourceAnchor(); - Point otherLoc0 = otherPort0.getOwner().getParent() - .getBounds().getLocation(); - // Dimension otherSize0 = - // ((BaseNodeFigure)otherPort0.getOwner().getParent()).getBaseFigure().getPreferredSize(); - // otherLoc0.x += otherSize0.width/2; - // otherLoc0.y += otherSize0.height/2; - - PolylineConnection conn1 = (PolylineConnection) port1 - .getConnections().get(0); - ConnectionAnchor otherPort1; - if (port1 == conn1.getSourceAnchor()) - otherPort1 = conn1.getTargetAnchor(); - else - otherPort1 = conn1.getSourceAnchor(); - Point otherLoc1 = otherPort1.getOwner().getParent() - .getBounds().getLocation(); -// Dimension otherSize1 = ((BaseNodeFigure) otherPort1 -// .getOwner().getParent()).getBaseFigure() -// .getPreferredSize(); - // otherLoc1.x += otherSize1.width/2; - // otherLoc1.y += otherSize1.height/2; - - switch (((PortFigure) port0.getOwner()).getOrientation()) { - case PositionConstants.NORTH: - case PositionConstants.SOUTH: - return otherLoc0.x - otherLoc1.x; - case PositionConstants.EAST: - case PositionConstants.WEST: - return otherLoc0.y - otherLoc1.y; - } - return 0; - } - }; - - // order the anchors on each side so connection lines don't cross - Collections.sort(topConnectionAnchors, comparePorts); - Collections.sort(leftConnectionAnchors, comparePorts); - Collections.sort(bottomConnectionAnchors, comparePorts); - Collections.sort(rightConnectionAnchors, comparePorts); - } - } - - protected void placeAnchors() { - determineAnchorPositions(); - if (anchorsVisible) { - Iterator it; - PortConnectionAnchor port; - int y, x; - - Dimension sz = baseFigure.getPreferredSize(); - LayoutManager layout = getLayoutManager(); - // CR389070: Figures are abbreviating rule figures names and making - // them unreadable - Dimension d = getAnchorSize(); - - // left ports - x = 0; - y = FigureConstants.PORT_SPACING / 2; - // CR374981: Long activity labels do not get wrapped or truncated - // keep a constant inset on all 4 sides of the icon - // if ( topConnectionAnchors.size()>0 ) - y += d.height; - y += (sz.height - (leftConnectionAnchors.size() * (d.height + FigureConstants.PORT_SPACING))) / 2; - it = leftConnectionAnchors.iterator(); - while (it.hasNext()) { - port = (PortConnectionAnchor) it.next(); - - Rectangle r = new Rectangle(x, y, -1, -1); - Rectangle oldrect = (Rectangle) layout.getConstraint(port - .getOwner()); - if (!r.equals(oldrect)) - layout.setConstraint(port.getOwner(), new Rectangle(x, y, - -1, -1)); - - y += d.height + FigureConstants.PORT_SPACING; - } - - // right ports - x = sz.width; - // CR374981: Long activity labels do not get wrapped or truncated - // if ( leftConnectionAnchors.size()>0 ) - x += d.width; - y = FigureConstants.PORT_SPACING / 2; - // CR374981: Long activity labels do not get wrapped or truncated - // if ( topConnectionAnchors.size()>0 ) - y += d.height; - y += (sz.height - (rightConnectionAnchors.size() * (d.height + FigureConstants.PORT_SPACING))) / 2; - it = rightConnectionAnchors.iterator(); - while (it.hasNext()) { - port = (PortConnectionAnchor) it.next(); - - Rectangle r = new Rectangle(x, y, -1, -1); - Rectangle oldrect = (Rectangle) layout.getConstraint(port - .getOwner()); - if (!r.equals(oldrect)) - layout.setConstraint(port.getOwner(), new Rectangle(x, y, - -1, -1)); - - y += d.height + FigureConstants.PORT_SPACING; - } - - // top ports - y = 0; - x = FigureConstants.PORT_SPACING / 2; - // CR374981: Long activity labels do not get wrapped or truncated - // if ( leftConnectionAnchors.size()>0 ) - x += d.width; - x += (sz.width - (topConnectionAnchors.size() * (d.width + FigureConstants.PORT_SPACING))) / 2; - it = topConnectionAnchors.iterator(); - while (it.hasNext()) { - port = (PortConnectionAnchor) it.next(); - - Rectangle r = new Rectangle(x, y, -1, -1); - Rectangle oldrect = (Rectangle) layout.getConstraint(port - .getOwner()); - if (!r.equals(oldrect)) - layout.setConstraint(port.getOwner(), new Rectangle(x, y, - -1, -1)); - - x += d.width + FigureConstants.PORT_SPACING; - } - - // bottom ports - y = sz.height; - // CR374981: Long activity labels do not get wrapped or truncated - // if ( topConnectionAnchors.size()>0 ) - y += d.height; - x = FigureConstants.PORT_SPACING / 2; - // CR374981: Long activity labels do not get wrapped or truncated - // if ( leftConnectionAnchors.size()>0 ) - x += d.width; - x += (sz.width - (bottomConnectionAnchors.size() * (d.width + FigureConstants.PORT_SPACING))) / 2; - it = bottomConnectionAnchors.iterator(); - while (it.hasNext()) { - port = (PortConnectionAnchor) it.next(); - - Rectangle r = new Rectangle(x, y, -1, -1); - Rectangle oldrect = (Rectangle) layout.getConstraint(port - .getOwner()); - if (!r.equals(oldrect)) - layout.setConstraint(port.getOwner(), new Rectangle(x, y, - -1, -1)); - - x += d.width + FigureConstants.PORT_SPACING; - } - } - } - - /** - * CR389070: Figures are abbreviating rule figures names and making them - * unreadable Anchor size is now dependent on icon size, not constant. Asks - * the connection anchor for its size. - */ - public Dimension getAnchorSize() { - Dimension d = new Dimension(FigureConstants.PORT_SIDE, - FigureConstants.PORT_SIDE); - if (!connectionAnchors.isEmpty()) { - Iterator iter = connectionAnchors.values().iterator(); - PortConnectionAnchor a = (PortConnectionAnchor) iter.next(); - d = a.getOwner().getPreferredSize(); - } - return d; - } - - public Insets getAnchorInsets() { - Insets in = new Insets(0, 0, 0, 0); - // CR389070: Figures are abbreviating rule figures names and making them - // unreadable - Dimension d = getAnchorSize(); - // CR374981: Long activity labels do not get wrapped or truncated - // if ( leftConnectionAnchors.size()>0 ) - in.left = d.width; - // CR374981: Long activity labels do not get wrapped or truncated - // if ( rightConnectionAnchors.size()>0 ) - in.right = d.width; - // CR374981: Long activity labels do not get wrapped or truncated - // if ( topConnectionAnchors.size()>0 ) - in.top = d.height; - // CR374981: Long activity labels do not get wrapped or truncated - // if ( bottomConnectionAnchors.size()>0 ) - in.bottom = d.height; - return in; - } - - public void invalidate() { - super.invalidate(); - } - - /** - * validate method override to arrange the input and output ports around the - * links of the node figures - */ - public void validate() { - placeAnchors(); - // CR389070: Figures are abbreviating rule figures names and making them - // unreadable - int x = 0; - int y = 0; - // if anchors are not visible (CompoundNodeFigure is maximized) always - // set position at 0,0 - if (anchorsVisible) { - Dimension d = getAnchorSize(); - // CR374981: Long activity labels do not get wrapped or truncated - // if ( leftConnectionAnchors.size()>0 ) - x = d.width; - // CR374981: Long activity labels do not get wrapped or truncated - // if ( topConnectionAnchors.size()>0 ) - y = d.height; - } - getLayoutManager().setConstraint(baseFigure, - new Rectangle(x, y, -1, -1)); - layout(); - super.validate(); - } - - /*************************************************************************** - * Miscellaneous - **************************************************************************/ - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.Figure#useLocalCoordinates() - */ - protected boolean useLocalCoordinates() { - return true; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.IFigure#setBounds(org.eclipse.draw2d.geometry.Rectangle) - */ - public void setBounds(Rectangle rect) { - Rectangle r = rect.getCopy(); - r.x = 0; - r.y = 0; - if (anchorsVisible) { - // CR389070: Figures are abbreviating rule figures names and making - // them unreadable - Dimension d = getAnchorSize(); - // CR374981: Long activity labels do not get wrapped or truncated - // if ( leftConnectionAnchors.size()>0 ) - { - r.x += d.width; - r.width -= d.width; - } - // CR374981: Long activity labels do not get wrapped or truncated - // if ( rightConnectionAnchors.size()>0 ) - r.width -= d.width; - // CR374981: Long activity labels do not get wrapped or truncated - // if ( topConnectionAnchors.size()>0 ) - { - r.y += d.height; - r.height -= d.height; - } - // CR374981: Long activity labels do not get wrapped or truncated - // if ( bottomConnectionAnchors.size()>0 ) - r.height -= d.height; - } - baseFigure.setBounds(r); - r.setLocation(rect.getLocation()); - super.setBounds(r); - } - - public Rectangle getBounds() { - Dimension size = baseFigure.getBounds().getSize(); - if (anchorsVisible) { - // CR389070: Figures are abbreviating rule figures names and making - // them unreadable - Dimension d = getAnchorSize(); - // CR374981: Long activity labels do not get wrapped or truncated - // if ( leftConnectionAnchors.size()>0 ) - size.width += d.width; - // CR374981: Long activity labels do not get wrapped or truncated - // if ( rightConnectionAnchors.size()>0 ) - size.width += d.width; - // CR374981: Long activity labels do not get wrapped or truncated - // if ( topConnectionAnchors.size()>0 ) - size.height += d.height; - // CR374981: Long activity labels do not get wrapped or truncated - // if ( bottomConnectionAnchors.size()>0 ) - size.height += d.height; - } - Rectangle r = super.getBounds(); - r.setSize(size); - return r; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.IFigure#getPreferredSize(int, int) - */ - public Dimension getPreferredSize(int wHint, int hHint) { - Dimension size = baseFigure.getPreferredSize(wHint, hHint).getCopy(); - if (anchorsVisible) { - // CR389070: Figures are abbreviating rule figures names and making - // them unreadable - Dimension d = getAnchorSize(); - // CR374981: Long activity labels do not get wrapped or truncated - // if ( leftConnectionAnchors.size()>0 ) - size.width += d.width; - // CR374981: Long activity labels do not get wrapped or truncated - // if ( rightConnectionAnchors.size()>0 ) - size.width += d.width; - // CR374981: Long activity labels do not get wrapped or truncated - // if ( topConnectionAnchors.size()>0 ) - size.height += d.height; - // CR374981: Long activity labels do not get wrapped or truncated - // if ( bottomConnectionAnchors.size()>0 ) - size.height += d.height; - } - return size; - } - - public static void moveToTop(IFigure parent, IFigure child) { - parent.getChildren().remove(child); - parent.getChildren().add(child); - } - - public void moveToTop() { - IFigure parent = getParent(); - IFigure child = this; - while (parent != null && !(parent instanceof Layer)) { - child = parent; - parent = parent.getParent(); - } - if (parent instanceof Layer) { - parent.getChildren().remove(child); - parent.getChildren().add(child); - } - } - - /*************************************************************************** - * IBaseFigure methods delegate to the baseFigure - **************************************************************************/ - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#setText(java.lang.String) - */ - public void setText(String text) { - baseFigure.setText(text); - } - - public void setIcon(Image image) { - baseFigure.setIcon(image); - } - - /** - * The description property of a DiagramNode is displayed as a tool tip. - * This method is used to set it. Passing a null or zero-length string will - * remove the tool tip - * - * @param text - * the description to use for this node's tool tip - * - * @see IBaseFigure#setToolTipText(java.lang.String) - */ - public void setToolTipText(String text) { - baseFigure.setToolTipText(text); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#addDecorator(com.sybase.stf.gem.diagram.editor.figures.BaseFigureDecorator) - */ - public void addDecorator(BaseFigureDecorator decorator) { - baseFigure.addDecorator(decorator); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#removeDecorator() - */ - public void removeDecorator() { - baseFigure.removeDecorator(); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#removeDecorator(int) - */ - public void removeDecorator(int position) { - baseFigure.removeDecorator(position); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#getDecorators() - */ - public List getDecorators() { - return baseFigure.getDecorators(); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#getText() - */ - public String getText() { - return baseFigure.getText(); - } - - /* - * CR374981: Long activity labels do not get wrapped or truncated This - * method was added to the IBaseFigure interface to support direct edit of - * figure labels on the canvas. - */ - public Rectangle getTextBounds() { - Rectangle r = baseFigure.getTextBounds().getCopy(); - r.x += getBounds().x; - r.y += getBounds().y; - return r; - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#getIcon() - */ - public Image getIcon() { - return baseFigure.getIcon(); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#getToolTipText() - */ - public String getToolTipText() { - return baseFigure.getToolTipText(); - } -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/ColorFontFieldEditor.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/ColorFontFieldEditor.java deleted file mode 100644 index 2bd8d2390..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/ColorFontFieldEditor.java +++ /dev/null @@ -1 +0,0 @@ -/*******************************************************************************
* Copyright (c) 2004, 2006 Sybase, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sybase, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.jst.jsf.facesconfig.ui.preference;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.resource.ColorRegistry;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.resource.StringConverter;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.FontDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
/**
*
* A field editor for a font type preference.
*
*/
public class ColorFontFieldEditor extends FieldEditor {
private static final int NUM_CONTROLS_WHEN_PREVIEWER = 4;
private static final int NUM_CONTROLS_WHEN_NO_PREVIEWER = 3;
/**
*
* The change font button, or <code>null</code> if none
*
* (before creation and after disposal).
*
*/
private Button changeFontButton = null;
/**
*
* The text for the change font button, or <code>null</code>
*
* if missing.
*
*/
private String changeButtonText;
/**
*
* The text for the preview, or <code>null</code> if no preview is desired
*
*/
private String previewText;
/**
*
* Font data for the chosen font button, or <code>null</code> if none.
*
*/
private FontData[] chosenFont;
/**
*
* Font color for the chosen font
*
*/
private RGB fontRGB;
/**
*
* The label that displays the selected font, or <code>null</code> if
* none.
*
*/
private Label valueControl;
/**
*
* The previewer, or <code>null</code> if none.
*
*/
private DefaultPreviewer previewer;
/**
*
* Internal font previewer implementation.
*
*/
private static class DefaultPreviewer {
private Text text;
private String string;
private Font font;
private Color color;
public DefaultPreviewer(String s, Composite parent) {
string = s;
text = new Text(parent, SWT.READ_ONLY | SWT.BORDER);
text.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
if (font != null)
font.dispose();
}
});
if (string != null)
text.setText(string);
}
public Control getControl() {
return text;
}
public void setFont(FontData[] fontData) {
if (font != null && !font.isDisposed())
font.dispose();
font = new Font(text.getDisplay(), fontData);
text.setFont(font);
}
public void setRGB(RGB fontRGB) {
if (fontRGB != null) {
if (color != null && !color.isDisposed())
color.dispose();
color = new Color(null, fontRGB);
text.setForeground(color);
}
}
public int getPreferredExtent() {
return 40;
}
}
/**
*
* Creates a new font field editor
*
*/
protected ColorFontFieldEditor() {
// control instantiation
}
/**
*
* Creates a font field editor with an optional preview area.
*
*
*
* @param name
* the name of the preference this field editor works on
*
* @param labelText
* the label text of the field editor
*
* @param previewAreaText
* the text used for the preview window. If it is
*
* <code>null</code> there will be no preview area,
*
* @param parent
* the parent of the field editor's control
*
*/
public ColorFontFieldEditor(
String name,
String labelText,
String previewAreaText,
Composite parent) {
init(name, labelText);
previewText = previewAreaText;
changeButtonText = JFaceResources.getString("openChange"); //$NON-NLS-1$
createControl(parent);
}
/**
*
* Creates a font field editor without a preview.
*
*
*
* @param name
* the name of the preference this field editor works on
*
* @param labelText
* the label text of the field editor
*
* @param parent
* the parent of the field editor's control
*
*/
public ColorFontFieldEditor(String name, String labelText, Composite parent) {
this(name, labelText, null, parent);
}
/*
* (non-Javadoc)
*
* Method declared on FieldEditor.
*
*/
protected void adjustForNumColumns(int numColumns) {
GridData data = new GridData();
if (valueControl.getLayoutData() != null)
data = (GridData) valueControl.getLayoutData();
data.horizontalSpan = numColumns - getNumberOfControls() + 1;
valueControl.setLayoutData(data);
}
/*
* (non-Javadoc)
*
* Method declared on FieldEditor.
*
*/
protected void applyFont() {
if (chosenFont != null && previewer != null)
previewer.setFont(chosenFont);
}
/*
* (non-Javadoc)
*
* Method declared on FieldEditor.
*
*/
protected void doFillIntoGrid(Composite parent, int numColumns) {
getLabelControl(parent);
valueControl = getValueControl(parent);
GridData gd = new GridData(GridData.FILL_HORIZONTAL
| GridData.GRAB_HORIZONTAL);
gd.horizontalSpan = numColumns - getNumberOfControls() + 1;
valueControl.setLayoutData(gd);
if (previewText != null) {
previewer = new DefaultPreviewer(previewText, parent);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.heightHint = previewer.getPreferredExtent();
gd.widthHint = previewer.getPreferredExtent();
previewer.getControl().setLayoutData(gd);
}
changeFontButton = getChangeControl(parent);
gd = new GridData();
/* TODO: this constant is deprecated IDialogConstants.BUTTON_HEIGHT but == 14*/
// C.B: I think the correct thing to do is simply to remove this code, since
// the deprecation mechanism says that button height is now determined by layout,
// so setting a heightHint prob won't do anything anyway.
// gd.heightHint = convertVerticalDLUsToPixels(changeFontButton,
// 14 );
int widthHint = convertHorizontalDLUsToPixels(changeFontButton,
IDialogConstants.BUTTON_WIDTH);
gd.widthHint = Math.max(widthHint, changeFontButton.computeSize(
SWT.DEFAULT, SWT.DEFAULT, true).x);
changeFontButton.setLayoutData(gd);
}
/*
* (non-Javadoc)
*
* Method declared on FieldEditor.
*
*/
protected void doLoad() {
if (changeFontButton == null)
return;
fontRGB = PreferenceConverter.getColor(getPreferenceStore(),
getPreferenceName() + "Color");
updateFont(PreferenceConverter.getFontDataArray(getPreferenceStore(),
getPreferenceName()));
}
/*
* (non-Javadoc)
*
* Method declared on FieldEditor.
*
*/
protected void doLoadDefault() {
if (changeFontButton == null)
return;
updateFont(PreferenceConverter.getDefaultFontDataArray(
getPreferenceStore(), getPreferenceName()));
}
/*
* (non-Javadoc)
*
* Method declared on FieldEditor.
*
*/
protected void doStore() {
if (chosenFont != null) {
PreferenceConverter.setValue(getPreferenceStore(),
getPreferenceName(), chosenFont);
}
if (fontRGB != null) {
PreferenceConverter.setValue(getPreferenceStore(),
getPreferenceName() + "Color", fontRGB);
}
}
/**
*
* Returns the change button for this field editor.
*
*
*
* @return the change button
*
*/
protected Button getChangeControl(Composite parent) {
if (changeFontButton == null) {
changeFontButton = new Button(parent, SWT.PUSH);
if (changeButtonText != null)
changeFontButton.setText(changeButtonText);
changeFontButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
FontDialog fontDialog = new FontDialog(changeFontButton
.getShell());
if (chosenFont != null)
fontDialog.setFontList(chosenFont);
if (fontRGB != null)
fontDialog.setRGB(fontRGB);
FontData font = fontDialog.open();
if (font != null) {
FontData[] oldFont = chosenFont;
if (oldFont == null)
oldFont = JFaceResources.getDefaultFont()
.getFontData();
setPresentsDefaultValue(false);
FontData[] newData = new FontData[1];
newData[0] = font;
fontRGB = fontDialog.getRGB();
updateFont(newData);
fireValueChanged(VALUE, oldFont[0], font);
}
}
});
changeFontButton.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent event) {
changeFontButton = null;
}
});
changeFontButton.setFont(parent.getFont());
setButtonLayoutData(changeFontButton);
} else
checkParent(changeFontButton, parent);
return changeFontButton;
}
/*
* (non-Javadoc)
*
* Method declared on FieldEditor.
*
*/
public int getNumberOfControls() {
if (previewer == null)
{
return NUM_CONTROLS_WHEN_NO_PREVIEWER;
}
return NUM_CONTROLS_WHEN_PREVIEWER;
}
/**
*
* Returns the preferred preview height.
*
*
*
* @return the height, or <code>-1</code> if no previewer
*
* is installed
*
*/
public int getPreferredPreviewHeight() {
if (previewer == null)
return -1;
return previewer.getPreferredExtent();
}
/**
*
* Returns the preview control for this field editor.
*
*
*
* @return the preview control
*
*/
public Control getPreviewControl() {
if (previewer == null)
return null;
return previewer.getControl();
}
/**
*
* Returns the value control for this field editor. The value control
*
* displays the currently selected font name.
*
*
*
* @return the value control
*
*/
protected Label getValueControl(Composite parent) {
if (valueControl == null) {
valueControl = new Label(parent, SWT.LEFT);
valueControl.setFont(parent.getFont());
valueControl.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent event) {
valueControl = null;
}
});
} else
checkParent(valueControl, parent);
return valueControl;
}
/**
*
* Sets the text of the change button.
*
*
*
* @param text
* the new text
*
*/
public void setChangeButtonText(String text) {
Assert.isNotNull(text);
changeButtonText = text;
if (changeFontButton != null)
changeFontButton.setText(text);
}
/**
*
* Updates the change font button and the previewer to reflect the
*
* newly selected font.
*
*/
private void updateFont(FontData font[]) {
FontData[] bestFont = JFaceResources.getFontRegistry().filterData(
font, valueControl.getDisplay());
// if we have nothing valid do as best we can
if (bestFont == null)
bestFont = getDefaultFontData();
// Now cache this value in the receiver
this.chosenFont = bestFont;
if (valueControl != null) {
if (fontRGB != null) {
ColorRegistry registry = JFaceResources.getColorRegistry();
Color color = registry.get(fontRGB.toString());
if (color == null) {
registry.put(fontRGB.toString(), fontRGB);
color = registry.get(fontRGB.toString());
}
valueControl.setForeground(color);
}
valueControl.setText(StringConverter.asString(chosenFont[0]));
}
if (previewer != null) {
previewer.setFont(bestFont);
}
}
/**
*
* Store the default preference for the field
*
* being edited
*
*/
protected void setToDefault() {
FontData[] defaultFontData = PreferenceConverter
.getDefaultFontDataArray(getPreferenceStore(),
getPreferenceName());
PreferenceConverter.setValue(getPreferenceStore(), getPreferenceName(),
defaultFontData);
}
/**
*
* Get the system default font data.
*
*/
private FontData[] getDefaultFontData() {
return valueControl.getDisplay().getSystemFont().getFontData();
}
/*
*
* @see FieldEditor.setEnabled(boolean,Composite).
*
*/
public void setEnabled(boolean enabled, Composite parent) {
super.setEnabled(enabled, parent);
getChangeControl(parent).setEnabled(enabled);
getValueControl(parent).setEnabled(enabled);
}
}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/ComboFieldEditor.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/ComboFieldEditor.java deleted file mode 100644 index cb344b36e..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/ComboFieldEditor.java +++ /dev/null @@ -1 +0,0 @@ -/*******************************************************************************
* Copyright (c) 2004, 2006 Sybase, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sybase, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.jst.jsf.facesconfig.ui.preference;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
/**
*
* A field editor for a combo box that allows the drop-down selection of one of
* a list of items.
*
*/
public class ComboFieldEditor extends FieldEditor {
/**
*
* The <code>Combo</code> widget.
*
*/
private Combo fCombo;
/**
*
* The value (not the name) of the currently selected item in the Combo
* widget.
*
*/
private String fValue;
/**
*
* The names (labels) and underlying values to populate the combo widget.
* These should be
*
* arranged as: { {name1, value1}, {name2, value2}, ...}
*
*/
private String[][] fEntryNamesAndValues;
public ComboFieldEditor(String name, String labelText,
String[][] entryNamesAndValues, Composite parent) {
init(name, labelText);
Assert.isTrue(checkArray(entryNamesAndValues));
fEntryNamesAndValues = entryNamesAndValues;
createControl(parent);
}
/**
*
* Checks whether given <code>String[][]</code> is of "type"
*
* <code>String[][2]</code>.
*
*
*
* @return <code>true</code> if it is ok, and <code>false</code>
* otherwise
*
*/
private boolean checkArray(String[][] table) {
if (table == null) {
return false;
}
for (int i = 0; i < table.length; i++) {
String[] array = table[i];
if (array == null || array.length != 2) {
return false;
}
}
return true;
}
/**
*
* @see FieldEditor#adjustForNumColumns(int)
*
*/
protected void adjustForNumColumns(int numColumns) {
if (numColumns > 1) {
Control control = getLabelControl();
int left = numColumns;
if (control != null) {
((GridData) control.getLayoutData()).horizontalSpan = 1;
left = left - 1;
}
((GridData) fCombo.getLayoutData()).horizontalSpan = left;
} else {
Control control = getLabelControl();
if (control != null) {
((GridData) control.getLayoutData()).horizontalSpan = 1;
}
((GridData) fCombo.getLayoutData()).horizontalSpan = 1;
}
}
/**
*
* @see FieldEditor#doFillIntoGrid(Composite, int)
*
*/
protected void doFillIntoGrid(Composite parent, int numColumns) {
int comboC = 1;
if (numColumns > 1) {
comboC = numColumns - 1;
}
Control control = getLabelControl(parent);
GridData gd = new GridData();
gd.horizontalSpan = 1;
control.setLayoutData(gd);
control = getComboBoxControl(parent);
gd = new GridData();
gd.horizontalSpan = comboC;
gd.horizontalAlignment = GridData.FILL;
control.setLayoutData(gd);
}
/**
*
* @see FieldEditor#doLoad()
*
*/
protected void doLoad() {
updateComboForValue(getPreferenceStore().getString(getPreferenceName()));
}
/**
*
* @see FieldEditor#doLoadDefault()
*
*/
protected void doLoadDefault() {
updateComboForValue(getPreferenceStore().getDefaultString(
getPreferenceName()));
}
/**
*
* @see FieldEditor#doStore()
*
*/
protected void doStore() {
if (fValue == null) {
getPreferenceStore().setToDefault(getPreferenceName());
return;
}
getPreferenceStore().setValue(getPreferenceName(), fValue);
}
/**
*
* @see FieldEditor#getNumberOfControls()
*
*/
public int getNumberOfControls() {
return 1;
}
/**
*
* Lazily create and return the Combo control.
*
*/
public Combo getComboBoxControl(Composite parent) {
if (fCombo == null) {
fCombo = new Combo(parent, SWT.READ_ONLY);
for (int i = 0; i < fEntryNamesAndValues.length; i++) {
fCombo.add(fEntryNamesAndValues[i][0], i);
}
fCombo.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent evt) {
String oldValue = fValue;
String name = fCombo.getText();
fValue = getValueForName(name);
setPresentsDefaultValue(false);
fireValueChanged(VALUE, oldValue, fValue);
}
});
}
return fCombo;
}
/**
*
* Given the name (label) of an entry, return the corresponding value.
*
*/
protected String getValueForName(String name) {
for (int i = 0; i < fEntryNamesAndValues.length; i++) {
String[] entry = fEntryNamesAndValues[i];
if (name.equals(entry[0])) {
return entry[1];
}
}
return fEntryNamesAndValues[0][0];
}
/**
*
* Set the name in the combo widget to match the specified value.
*
*/
protected void updateComboForValue(String value) {
fValue = value;
for (int i = 0; i < fEntryNamesAndValues.length; i++) {
if (value.equals(fEntryNamesAndValues[i][1])) {
fCombo.setText(fEntryNamesAndValues[i][0]);
return;
}
}
if (fEntryNamesAndValues.length > 0) {
fValue = fEntryNamesAndValues[0][1];
}
}
}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/CompoundFigureListener.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/CompoundFigureListener.java deleted file mode 100644 index 69e0ad470..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/CompoundFigureListener.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.preference; - -/** - * @author bbrodt - * - * Interface definition for listeners of CompoundFigure events. Events are - * generated when a user presses a different tab (tabChanged event) or presses - * one of the minimize/maximize/restore buttons (stateChanged event) - */ -public interface CompoundFigureListener extends WindowFigureListener { - void stateChanged(int oldState, int newState); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/CompoundNodeFigure.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/CompoundNodeFigure.java deleted file mode 100644 index 6ddceb61f..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/CompoundNodeFigure.java +++ /dev/null @@ -1,507 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.preference; - -import java.util.Iterator; - -import org.eclipse.draw2d.ActionEvent; -import org.eclipse.draw2d.ActionListener; -import org.eclipse.draw2d.FreeformFigure; -import org.eclipse.draw2d.FreeformListener; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.Layer; -import org.eclipse.draw2d.LayoutManager; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Insets; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.Image; - -/** - * The figure for Compound nodes - */ -public class CompoundNodeFigure extends BaseNodeFigure implements - FreeformFigure, IContainerFigure { - public final static int MINIMIZED = 1; - - public final static int RESTORED = 2; - - public final static int MAXIMIZED = 3; - - private int state = RESTORED; - - private TitleBarButton minButton; - - private TitleBarButton maxButton; - - private IconFigure iconFigure; - - private WindowFigure windowFigure; - - private static String DEFAULT_NAME = "CompoundNode"; - - private static String DEFAULT_ICON = "editor/CompoundNode.gif"; - - private static Image minimizeImage = EditorPlugin.getDefault().getImage( - "minimize.gif"); - - private static Image minimizeHiliteImage = EditorPlugin.getDefault() - .getImage("minimize_hilite.gif"); - - private static Image maximizeImage = EditorPlugin.getDefault().getImage( - "maximize.gif"); - - private static Image maximizeHiliteImage = EditorPlugin.getDefault() - .getImage("maximize_hilite.gif"); - - private static Image restoreImage = EditorPlugin.getDefault().getImage( - "restore.gif"); - - private static Image restoreHiliteImage = EditorPlugin.getDefault() - .getImage("restore_hilite.gif"); - - public CompoundNodeFigure() { - // create all of the figures and adornments: - // the icon figure - super(new IconFigure(DEFAULT_NAME, EditorPlugin.getDefault().getImage( - DEFAULT_ICON))); - iconFigure = (IconFigure) getBaseFigure(); - // and the window figure - windowFigure = new WindowFigure(); - windowFigure.setForegroundColor(IconFigure.defaultForegroundColor); - windowFigure.setFont(IconFigure.defaultFont); - - // then the minimize/maximize buttons. - // Note that the maxButton is also used for the "Restore" action - // TODO: - // The reason for putting these buttons in CompoundNodeFigure instead of - // WindowFigure where they really belong, is that the TitleBarButton is - // a - // draw2d Button (which subclasses Figure) and these must be placed in - // the - // titlebar (i.e. a SchemeBorder) because that's where they belong. The - // problem - // with this is that the Figure.paint() method first draws all of its - // children - // figures, then the border which means that the buttons would be - // obscured. - // This should be fixed as time allows and the WindowFigureListener - // interface - // should then also be modified to include a buttonPressed() - // notification - // for which CompoundNodeFigure can be a listener. - minButton = new TitleBarButton(minimizeImage, minimizeHiliteImage, - null, null); - maxButton = new TitleBarButton(maximizeImage, maximizeHiliteImage, - restoreImage, restoreHiliteImage); - - add(minButton); - add(maxButton); - - minButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { - setState(CompoundNodeFigure.MINIMIZED); - } - }); - maxButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { - setState(maxButton.getState() ? CompoundNodeFigure.MAXIMIZED - : CompoundNodeFigure.RESTORED); - } - }); - - // show as a normal window initially - showIcon(); - - // testing BaseFigureDecorators: - // BaseFigureDecorator decorator; - // decorator = new - // BaseFigureDecorator(EditorPlugin.getDefault().getGEMImage("delete.gif"), - // "top right", - // PositionConstants.NORTH_EAST); - // addDecorator(decorator); - // decorator = new - // BaseFigureDecorator(EditorPlugin.getDefault().getGEMImage("delete.gif"), - // "top left", - // PositionConstants.NORTH_WEST); - // addDecorator(decorator); - // decorator = new - // BaseFigureDecorator(EditorPlugin.getDefault().getGEMImage("delete.gif"), - // "bottom right", - // PositionConstants.SOUTH_EAST); - // addDecorator(decorator); - // decorator = new - // BaseFigureDecorator(EditorPlugin.getDefault().getGEMImage("delete.gif"), - // "bottom left", - // PositionConstants.SOUTH_WEST); - // addDecorator(decorator); - } - - public void setOpaque(boolean flag) { - windowFigure.setOpaque(flag); - } - - /* - * Remove the window figure and its buttons and replace them with the icon - * figure. - */ - private void showIcon() { - // CR400779: GEM minimizing a complex activity sometimes leaves junk on - // the screen - setVisible(false); - minButton.setVisible(false); - maxButton.setVisible(false); - super.setBaseFigure(iconFigure); - - setAnchorsVisible(true); - // CR400779: GEM minimizing a complex activity sometimes leaves junk on - // the screen - setVisible(true); - } - - /* - * Remove the icon figure and replace with the window figure. Make sure the - * buttons are reset to their correct states. - */ - private void showWindow() { - // CR400779: GEM minimizing a complex activity sometimes leaves junk on - // the screen - setVisible(false); - if (state == RESTORED) { - super.setBaseFigure(windowFigure); - - minButton.setVisible(true); - minButton.setState(false); - minButton.setToolTip(new Label("Minimize")); - - maxButton.setVisible(true); - maxButton.setState(false); - maxButton.setToolTip(new Label("Maximize")); - - setAnchorsVisible(true); - } else if (state == MAXIMIZED) { - setAnchorsVisible(false); - - Rectangle constraint = new Rectangle(0, 0, -1, -1); - IFigure parent = getParent(); - if (parent != null) { - constraint = parent.getBounds().getCopy(); - constraint.width += constraint.x; - constraint.height += constraint.y; - constraint.x = 0; - constraint.y = 0; - } - - super.setBaseFigure(windowFigure, constraint); - if (parent != null && parent.getLayoutManager() != null) { - // System.out.println("CompoundNode.showWindow: maximize - // "+constraint); - parent.getLayoutManager().setConstraint(this, constraint); - } - - // the maximize button is used for both Maximize and Restore actions - minButton.setVisible(false); - - maxButton.setVisible(true); - maxButton.setState(true); - maxButton.setToolTip(new Label("Restore")); - } - // CR400779: GEM minimizing a complex activity sometimes leaves junk on - // the screen - setVisible(true); - } - - public void addDecorator(BaseFigureDecorator decorator) { - iconFigure.addDecorator(decorator); - } - - public void removeDecorator() { - iconFigure.removeDecorator(); - } - - public void removeDecorator(int position) { - iconFigure.removeDecorator(position); - } - - public void setHilight(boolean flag) { - windowFigure.setHighlight(flag); - if (flag) - moveToTop(); - } - - public void setText(String name) { - iconFigure.setText(name); - windowFigure.setText(name); - } - - public void setIcon(Image image) { - iconFigure.setIcon(image); - } - - public void setToolTipText(String text) { - iconFigure.setToolTipText(text); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.Figure#layout() - */ - public void validate() { - LayoutManager layout = getLayoutManager(); - if (state == MINIMIZED) { - // iconFigure.validate(); - } else if (state == RESTORED) { - Rectangle r = windowFigure.getBounds().getCopy(); - Insets i = windowFigure.getInsets(); - Dimension dm = maxButton.getSize(); - Insets p = windowFigure.getTabbedTitleBarBorder().getPadding(); - layout.setConstraint(maxButton, new Rectangle(r.x + r.width - - dm.width - p.right - i.right, r.y + p.top + i.top - - dm.height - i.bottom, -1, -1)); - layout.setConstraint(minButton, new Rectangle(r.x + r.width - 2 - * dm.width - 2 * p.right - i.right, r.y + p.top + i.top - - dm.height - i.bottom, -1, -1)); - } else if (state == MAXIMIZED) { - // CR387660: restore icon on complex activity bounces around - // we need to use the parent's bounds when maximized instead of - // current window bounds - if (getParent() == null) - return; - Rectangle r = getParent().getBounds().getCopy(); - Insets i = windowFigure.getInsets(); - Dimension dm = maxButton.getSize(); - Insets p = windowFigure.getTabbedTitleBarBorder().getPadding(); - layout.setConstraint(maxButton, new Rectangle(r.x + r.width - - dm.width - p.right - i.right, r.y + p.top, -1, -1)); - } - super.validate(); - } - - public IconFigure getIconFigure() { - return iconFigure; - } - - /** - * @return the window figure - */ - public WindowFigure getWindowFigure() { - return windowFigure; - } - - public void setFont(Font f) { - iconFigure.setFont(f); - windowFigure.setFont(f); - } - - public void setForegroundColor(Color c) { - iconFigure.setForegroundColor(c); - windowFigure.setForegroundColor(c); - } - - public void setBackgroundColor(Color c) { - iconFigure.setBackgroundColor(c); - windowFigure.setBackgroundColor(c); - } - - public int getState() { - return state; - } - - public void setState(int newState) { - int oldState = state; - state = newState; - - if (state == CompoundNodeFigure.MINIMIZED) { - if (getParent() != null && getParent().getLayoutManager() != null) { - Rectangle constraint = (Rectangle) getParent() - .getLayoutManager().getConstraint(this); - constraint.width = -1; - constraint.height = -1; - } - showIcon(); - } else if (state == CompoundNodeFigure.MAXIMIZED) { - if (getParent() != null && getParent().getLayoutManager() != null) { - Rectangle constraint = (Rectangle) getParent() - .getLayoutManager().getConstraint(this); - constraint.x = 0; - constraint.y = 0; - constraint.width = -1; - constraint.height = -1; - } - showWindow(); - } else if (state == CompoundNodeFigure.RESTORED) { - if (getParent() != null && getParent().getLayoutManager() != null) { - Rectangle constraint = (Rectangle) getParent() - .getLayoutManager().getConstraint(this); - constraint.setSize(windowFigure.getBounds().getSize()); - } - showWindow(); - } - fireStateChanged(oldState, newState); - } - - protected void fireStateChanged(int oldState, int newState) { - Object l[] = windowFigure.getTabbedTitleBarBorder().getListeners(); - for (int i = 0; i < l.length; ++i) { - if (l[i] instanceof CompoundFigureListener) - ((CompoundFigureListener) l[i]) - .stateChanged(oldState, newState); - } - } - - public Point getScrollPosition() { - return windowFigure.getScrollPosition(); - } - - public int addTab(String s) { - return windowFigure.addTab(s); - } - - public void removeTab(int index) { - windowFigure.removeTab(index); - } - - public void setCurrentTab(int index) { - windowFigure.setCurrentTab(index); - } - - public int getCurrentTab() { - return windowFigure.getCurrentTab(); - } - - public void setContents(int index, Object contents) { - windowFigure.setContents(index, contents); - } - - public Object getContents(int index) { - return windowFigure.getContents(index); - } - - public Object getContents() { - return windowFigure.getContents(); - } - - public TabbedTitleBarBorder getTabbedTitleBarBorder() { - return windowFigure.getTabbedTitleBarBorder(); - } - - public void addCompoundFigureListener(CompoundFigureListener listener) { - windowFigure.getTabbedTitleBarBorder() - .addTabbedWindowListener(listener); - } - - public void removeCompoundFigureListener(CompoundFigureListener listener) { - windowFigure.getTabbedTitleBarBorder().removeTabbedWindowListener( - listener); - } - - public Dimension getMinimumSize(int wHint, int hHint) { - if (getState() == CompoundNodeFigure.RESTORED) { - Dimension d = windowFigure.getMinimumSize(wHint, hHint); - d.width += minButton.getSize().width - + maxButton.getSize().width - + 2 - * windowFigure.getTabbedTitleBarBorder().getPadding() - .getWidth(); - return d; - } - if (getState() == CompoundNodeFigure.MINIMIZED) - return iconFigure.getMinimumSize(wHint, hHint); - return super.getMinimumSize(wHint, hHint); - } - - // ////////////////////////////////////////////////////////////////////// - // FreeformFigure methods - // ////////////////////////////////////////////////////////////////////// - - private WindowFreeformHelper helper = new WindowFreeformHelper(this); - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.FreeformFigure#addFreeformListener(org.eclipse.draw2d.FreeformListener) - */ - public void addFreeformListener(FreeformListener listener) { - addListener(FreeformListener.class, listener); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.FreeformFigure#fireExtentChanged() - */ - public void fireExtentChanged() { - // CR389495: Working with nested complex activities causes in the BP - // editor causes lockup - // not specifically related to this CR, but caused a problem when - // compound node - // was moved beyond viewport's client area and de-selected - this would - // resize - // the viewport so that compound node no longer participated in bounds - // calculation. - if (state == MAXIMIZED) { - Iterator iter = getListeners(FreeformListener.class); - while (iter.hasNext()) - ((FreeformListener) iter.next()).notifyFreeformExtentChanged(); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.FreeformFigure#getFreeformExtent() - */ - public Rectangle getFreeformExtent() { - // CR389495: Working with nested complex activities causes in the BP - // editor causes lockup - // same as above - if (state == MAXIMIZED) - return helper.getFreeformExtent(); - return getBounds(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.FreeformFigure#removeFreeformListener(org.eclipse.draw2d.FreeformListener) - */ - public void removeFreeformListener(FreeformListener listener) { - removeListener(FreeformListener.class, listener); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.FreeformFigure#setFreeformBounds(org.eclipse.draw2d.geometry.Rectangle) - */ - public void setFreeformBounds(Rectangle bounds) { - if (getState() == MAXIMIZED) - helper.setFreeformBounds(bounds); - } - - /* - * CR389070: Figures are abbreviating rule figures names and making them - * unreadable New Method on IContainerFigure - * - * @see com.sybase.stf.gem.diagram.editor.figures.IContainerFigure#getLayer(java.lang.Object) - */ - public Layer getLayer(Object key) { - if (windowFigure != null && windowFigure.isVisible()) - return windowFigure.getLayer(key); - return null; - } -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/FigureConstants.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/FigureConstants.java deleted file mode 100644 index 81cfa2626..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/FigureConstants.java +++ /dev/null @@ -1 +0,0 @@ -/*******************************************************************************
* Copyright (c) 2004, 2006 Sybase, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sybase, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.jst.jsf.facesconfig.ui.preference;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.swt.graphics.Color;
/**
*
*
*
* Constants for figure dimensions, etc. used in the sample app
*
*/
public class FigureConstants
{
/**
*
*
*
*/
private FigureConstants()
{
// no external instantiation
}
public static final int PORT_SIDE = 10; // (int)Math.round( ARROW_SIDE *
// Math.cos( 30 ) );
public static final Color PORT_INPUT_TRIANGLE_COLOR = ColorConstants.black;
public static final Color PORT_OUTPUT_TRIANGLE_COLOR = ColorConstants.black;
public static final Color PORT_EXCEPTION_TRIANGLE_COLOR = ColorConstants.red;
public static final Color PORT_START_COLOR = ColorConstants.green;
public static final Color PORT_FINISH_COLOR = ColorConstants.red;
// CR389070: Figures are abbreviating rule figures names and making them
// unreadable
public static final int PORT_SPACING = 2; // ARROW_SIDE / 2;
public static final Color PORT_INPUT_RECTANGLE_COLOR = ColorConstants.white;
public static final Color PORT_OUTPUT_RECTANGLE_COLOR = ColorConstants.white;
// this is the type of port; input or output
public static int INPUT_PORT = 0;
public static int OUTPUT_PORT = 1;
}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/GEMPreferences.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/GEMPreferences.java deleted file mode 100644 index 781254c77..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/GEMPreferences.java +++ /dev/null @@ -1,718 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.preference; - -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.jface.preference.BooleanFieldEditor; -import org.eclipse.jface.preference.ColorFieldEditor; -import org.eclipse.jface.preference.FieldEditorPreferencePage; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.IntegerFieldEditor; -import org.eclipse.jface.preference.PreferenceConverter; -import org.eclipse.jface.resource.ColorRegistry; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Group; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; - -/** - * This class represents a preference page that is contributed to the - * Preferences dialog. By subclassing <samp>FieldEditorPreferencePage </samp>, - * we can use the field support built into JFace that allows us to create a page - * that is small and knows how to save, restore and apply itself. - * <p> - * This page is used to modify preferences only. They are stored in the - * preference store that belongs to the main plug-in class. That way, - * preferences can be accessed directly via the preference store. - */ - -public class GEMPreferences extends FieldEditorPreferencePage implements - IWorkbenchPreferencePage { - // appearance - /** - * Key for preference for whether or not the intro editor should be shown - */ - public final static String SHOW_INTRO_EDITOR = "ShowIntroEditor"; //$NON-NLS-1$ - - public final static String USE_SYSTEM_COLORS = "UseSystemColors"; //$NON-NLS-1$ - - public final static String CANVAS_COLOR = "CanvasColor"; //$NON-NLS-1$ - - public final static String FIGURE_LABEL_FONT = "FigureLabelFont"; //$NON-NLS-1$ - - public final static String FIGURE_LABEL_FONT_COLOR = "FigureLabelFontColor"; //$NON-NLS-1$ - - public final static String LABEL_PLACEMENT = "LabelPlacement"; //$NON-NLS-1$ - - public final static String INPUT_PORT_COLOR = "InputPortColor"; //$NON-NLS-1$ - - public final static String OUTPUT_PORT_COLOR = "OutputPortColor"; //$NON-NLS-1$ - - public final static String SHOW_LINE_LABELS = "ShowLineLabels"; //$NON-NLS-1$ - - public final static String LINE_LABEL_FONT = "LineLabelFont"; //$NON-NLS-1$ - - public final static String LINE_LABEL_FONT_COLOR = "LineLabelFontColor"; //$NON-NLS-1$ - - public final static String LINE_LABEL_COLOR = "LineLabelColor"; //$NON-NLS-1$ - - public final static String LINE_WIDTH = "LineWidth"; //$NON-NLS-1$ - - public final static String LINE_COLOR = "LineColor"; //$NON-NLS-1$ - - public final static String LINE_ROUTING = "LineRouting"; //$NON-NLS-1$ - - public final static String SNAP_TO_GRID = "SnapToGrid"; //$NON-NLS-1$ - - public final static String SNAP_TO_GEOMETRY = "SnapToGeometry"; //$NON-NLS-1$ - - public final static String GRID_WIDTH = "GridWidth"; //$NON-NLS-1$ - - public final static String GRID_HEIGHT = "GridHeight"; //$NON-NLS-1$ - - public final static String GRID_COLOR = "GridColor"; //$NON-NLS-1$ - - public final static String LABEL_PLACEMENT_TOP = "Top"; //$NON-NLS-1$ - - public final static String LABEL_PLACEMENT_BOTTOM = "Bottom"; //$NON-NLS-1$ - - public final static String LABEL_PLACEMENT_LEFT = "Left"; //$NON-NLS-1$ - - public final static String LABEL_PLACEMENT_RIGHT = "Right"; //$NON-NLS-1$ - - // "Direct" routing was intended for connections lines without bendpoints; - // this has been removed because it is unnecessary. - // public final static String LINE_ROUTING_DIRECT = "Direct"; - // "Manhattan" line routing creates orthogonal lines - public final static String LINE_ROUTING_MANHATTAN = "Manhattan"; //$NON-NLS-1$ - - // "Manual" routing allows user to create bendpoints - public final static String LINE_ROUTING_MANUAL = "Manaul"; //$NON-NLS-1$ - - private final static String[][] m_lineRoutingLabels = { - // display, key - // { GEMPlugin.getResourceString("CanvasPreferences.LABEL.Direct"), - // LINE_ROUTING_DIRECT }, //$NON-NLS-1$ //$NON-NLS-2$ - { - PreferenceMessages.CanvasPreferences_LABEL_Manual, LINE_ROUTING_MANUAL }, //$NON-NLS-1$ //$NON-NLS-2$ - { - PreferenceMessages.CanvasPreferences_LABEL_Manhattan, LINE_ROUTING_MANHATTAN } //$NON-NLS-1$ //$NON-NLS-2$ - }; - - private final static String[][] m_labelPlacementLabels = { - { - PreferenceMessages.CanvasPreferences_LABEL_Top, LABEL_PLACEMENT_TOP }, //$NON-NLS-1$ //$NON-NLS-2$ - { - PreferenceMessages.CanvasPreferences_LABEL_Bottom, LABEL_PLACEMENT_BOTTOM }, //$NON-NLS-1$ //$NON-NLS-2$ - { - PreferenceMessages.CanvasPreferences_LABEL_Left, LABEL_PLACEMENT_LEFT }, //$NON-NLS-1$ //$NON-NLS-2$ - { - PreferenceMessages.CanvasPreferences_LABEL_Right, LABEL_PLACEMENT_RIGHT } //$NON-NLS-1$ //$NON-NLS-2$ - }; - - private Group canvasGroup; - - private Group iconGroup; - - private Group lineGroup; - - private BooleanField useSystemColors; - - private ColorFieldEditor canvasColor; - - private BooleanField snapToGrid; - - private IntegerFieldEditor gridWidth; - - private IntegerFieldEditor gridHeight; - - private ColorFieldEditor gridColor; - - private BooleanField showLineLabels; - - private ColorFieldEditor lineLabelColor; - - private ColorFieldEditor lineColor; - - private ColorFontFieldEditor iconFont; - - private ColorFontFieldEditor lineFont; - - // private ColorFieldEditor inputPortColor; - // - // private ColorFieldEditor outputPortColor; - - // CR392586: resource leaks - // at least keep leaks bounded... -// private static Hashtable resourceRegistry = new Hashtable(); - - private class BooleanField extends BooleanFieldEditor { - private Composite parent; - - /** - * @param name - * @param label - * @param parent - */ - public BooleanField(String name, String label, Composite parent) { - super(name, label, parent); - this.parent = parent; - } - - /** - * @return the change control button - */ - public Button getButton() { - return getChangeControl(parent); - } - } - - /** - * Constructor - */ - public GEMPreferences() { - super(GRID); - // FIXME: we should be encapsulating what pref store is used for all callers of this class - setPreferenceStore(EditorPlugin.getDefault().getPreferenceStore()); - setDescription(PreferenceMessages.GEMPreferences_description); - initializeDefaults(); - } - - /** - * Sets the default values of the preferences. - */ - private void initializeDefaults() { - IPreferenceStore store = getPreferenceStore(); - Font f = JFaceResources.getFontRegistry().get( - JFaceResources.DEFAULT_FONT); - - store.setDefault(SHOW_INTRO_EDITOR, true); - store.setDefault(USE_SYSTEM_COLORS, true); - PreferenceConverter.setDefault(store, CANVAS_COLOR, new RGB(255, 255, - 255)); - PreferenceConverter.setDefault(store, FIGURE_LABEL_FONT, f - .getFontData()); - store.setDefault(LINE_WIDTH, 1); - store.setDefault(LINE_ROUTING, getLineRoutingLabels()[0][1]); - store.setDefault(SHOW_LINE_LABELS, true); - PreferenceConverter.setDefault(store, LINE_COLOR, new RGB(0, 0, 0)); - PreferenceConverter.setDefault(store, LINE_LABEL_COLOR, new RGB(255, - 255, 255)); - PreferenceConverter.setDefault(store, LINE_LABEL_FONT, f.getFontData()); - store.setDefault(SNAP_TO_GEOMETRY, true); - store.setDefault(SNAP_TO_GRID, true); - store.setDefault(GRID_WIDTH, 12); - store.setDefault(GRID_HEIGHT, 12); - PreferenceConverter.setDefault(store, GRID_COLOR, - new RGB(230, 230, 230)); - } - - /** - * Creates the field editors. Field editors are abstractions of the common - * GUI blocks needed to manipulate various types of preferences. Each field - * editor knows how to save and restore itself. - */ - - public void createFieldEditors() { - - // note, we aren't saving the reference. It's assumed that parent - // worries about destruction, persistence etc. - addBooleanField( - SHOW_INTRO_EDITOR, - PreferenceMessages.EditorPreferences_LABEL_ShowIntroEditor, - getFieldEditorParent()); - - useSystemColors = addBooleanField( - USE_SYSTEM_COLORS, - PreferenceMessages.CanvasPreferenceTab_LABEL_UseSystemColors, - getFieldEditorParent()); - - canvasGroup = new Group(getFieldEditorParent(), SWT.NULL); - lineGroup = new Group(getFieldEditorParent(), SWT.NULL); - iconGroup = new Group(getFieldEditorParent(), SWT.NULL); - - canvasGroup.setText(PreferenceMessages.CanvasPreferenceTab_LABEL_Canvas); //$NON-NLS-1$ - canvasColor = addColorField( - CANVAS_COLOR, - PreferenceMessages.CanvasPreferenceTab_LABEL_BackgroundColor, canvasGroup); //$NON-NLS-1$ - addBooleanField( - SNAP_TO_GEOMETRY, - PreferenceMessages.CanvasPreferenceTab_LABEL_SnapToGeometry, canvasGroup); //$NON-NLS-1$ - snapToGrid = addBooleanField( - SNAP_TO_GRID, - PreferenceMessages.CanvasPreferenceTab_LABEL_SnapToGrid, canvasGroup); //$NON-NLS-1$ - gridColor = addColorField( - GRID_COLOR, - PreferenceMessages.CanvasPreferenceTab_LABEL_GridLineColor, canvasGroup); //$NON-NLS-1$ - gridWidth = addIntegerField( - GRID_WIDTH, - PreferenceMessages.CanvasPreferenceTab_LABEL_GridWidth, canvasGroup); //$NON-NLS-1$ - gridHeight = addIntegerField( - GRID_HEIGHT, - PreferenceMessages.CanvasPreferenceTab_LABEL_GridHeight, canvasGroup); //$NON-NLS-1$ - - iconGroup.setText(PreferenceMessages.CanvasPreferenceTab_LABEL_IconGroup); //$NON-NLS-1$ - iconFont = addFontField( - FIGURE_LABEL_FONT, - PreferenceMessages.CanvasPreferenceTab_LABEL_IconLabelFont, iconGroup); //$NON-NLS-1$ - addComboField(LABEL_PLACEMENT, PreferenceMessages.CanvasPreferenceTab_LABEL_LabelPlacement, //$NON-NLS-1$ - getLabelPlacementLabels(), iconGroup); - // inputPortColor = addColorField( - // INPUT_PORT_COLOR, - // EditorPlugin - // .getResourceString("CanvasPreferenceTab.LABEL.InputPortColor"), - // iconGroup); //$NON-NLS-1$ - // outputPortColor = addColorField( - // OUTPUT_PORT_COLOR, - // EditorPlugin - // .getResourceString("CanvasPreferenceTab.LABEL.OutputPortColor"), - // iconGroup); //$NON-NLS-1$ - - lineGroup.setText(PreferenceMessages.CanvasPreferenceTab_LABEL_LineGroup); //$NON-NLS-1$ - showLineLabels = addBooleanField(SHOW_LINE_LABELS, PreferenceMessages.CanvasPreferenceTab_LABEL_ShowLineLabels, - lineGroup); - lineFont = addFontField( - LINE_LABEL_FONT, - PreferenceMessages.CanvasPreferenceTab_LABEL_LineLabelFont, lineGroup); //$NON-NLS-1$ - lineLabelColor = addColorField( - LINE_LABEL_COLOR, - PreferenceMessages.CanvasPreferenceTab_LABEL_LineLabelColor, lineGroup); //$NON-NLS-1$ - lineColor = addColorField( - LINE_COLOR, - PreferenceMessages.CanvasPreferenceTab_LABEL_LineColor, lineGroup); //$NON-NLS-1$ - addIntegerField( - LINE_WIDTH, - PreferenceMessages.CanvasPreferenceTab_LABEL_LineWidth, lineGroup); //$NON-NLS-1$ - addComboField(LINE_ROUTING, PreferenceMessages.CanvasPreferenceTab_LABEL_LineRouting, //$NON-NLS-1$ - getLineRoutingLabels(), lineGroup); - } - - protected void initialize() { - // Color use: Default canvas colors should pick up system defaults - // enable or disable all of the color and font selection controls in the - // preference dialog - // depending on whether the "Use System Colors" checkbox is selected. - super.initialize(); - - ((GridLayout) getFieldEditorParent().getLayout()).numColumns = 2; - - canvasGroup.setLayout(new GridLayout(3, false)); - canvasGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING)); - canvasColor.fillIntoGrid(canvasGroup, 3); - gridColor.fillIntoGrid(canvasGroup, 3); - - iconGroup.setLayout(new GridLayout(3, false)); - iconGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING)); - iconFont.fillIntoGrid(iconGroup, 3); - - lineGroup.setLayout(new GridLayout(3, false)); - lineGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING)); - lineColor.fillIntoGrid(lineGroup, 3); - lineLabelColor.fillIntoGrid(lineGroup, 3); - lineFont.fillIntoGrid(lineGroup, 3); - - boolean userColorsValue = !useSystemColors.getBooleanValue(); - boolean showLineLabelsValue = showLineLabels.getBooleanValue(); - boolean snapToGridValue = snapToGrid.getBooleanValue(); - canvasColor.setEnabled(userColorsValue, canvasGroup); - gridColor.setEnabled(snapToGridValue && userColorsValue, canvasGroup); - iconFont.setEnabled(userColorsValue, iconGroup); - // inputPortColor.setEnabled(userColorsValue, iconGroup); - // outputPortColor.setEnabled(userColorsValue, iconGroup); - lineColor.setEnabled(userColorsValue, lineGroup); - lineLabelColor.setEnabled(showLineLabelsValue && userColorsValue, - lineGroup); - lineFont.setEnabled(showLineLabelsValue && userColorsValue, lineGroup); - gridWidth.setEnabled(snapToGridValue, canvasGroup); - gridHeight.setEnabled(snapToGridValue, canvasGroup); - - useSystemColors.getButton().addSelectionListener( - new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - boolean userColorsValue_ = !useSystemColors - .getBooleanValue(); - boolean showLineLabelsValue_ = showLineLabels - .getBooleanValue(); - boolean snapToGridValue_ = snapToGrid.getBooleanValue(); - - canvasColor.setEnabled(userColorsValue_, canvasGroup); - gridColor - .setEnabled(snapToGridValue_ && userColorsValue_, - canvasGroup); - iconFont.setEnabled(userColorsValue_, iconGroup); - // inputPortColor.setEnabled(userColorsValue, - // iconGroup); - // outputPortColor.setEnabled(userColorsValue, - // iconGroup); - lineColor.setEnabled(userColorsValue_, lineGroup); - lineLabelColor.setEnabled(showLineLabelsValue_ - && userColorsValue_, lineGroup); - lineFont.setEnabled(showLineLabelsValue_ - && userColorsValue_, lineGroup); - } - }); - - showLineLabels.getButton().addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - boolean userColorsValue_ = !useSystemColors.getBooleanValue(); - boolean showLineLabelsValue_ = showLineLabels.getBooleanValue(); - lineLabelColor.setEnabled(showLineLabelsValue_ - && userColorsValue_, lineGroup); - lineFont.setEnabled(showLineLabelsValue_ && userColorsValue_, - lineGroup); - } - }); - - snapToGrid.getButton().addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - boolean userColorsValue_ = !useSystemColors.getBooleanValue(); - boolean snapToGridValue_ = snapToGrid.getBooleanValue(); - - gridColor.setEnabled(snapToGridValue_ && userColorsValue_, - canvasGroup); - gridWidth.setEnabled(snapToGridValue_, canvasGroup); - gridHeight.setEnabled(snapToGridValue_, canvasGroup); - } - }); - - } - - public void init(IWorkbench workbench) { - // no initialization - } - - private ColorFieldEditor addColorField(String name, String labelText, - Composite parent) { - ColorFieldEditor f = new ColorFieldEditor(name, labelText, parent); - addField(f); - return f; - } - - private ComboFieldEditor addComboField(String name, String labelText, - String[][] entryNamesAndValues, Composite parent) { - ComboFieldEditor f = new ComboFieldEditor(name, labelText, - entryNamesAndValues, parent); - addField(f); - return f; - } - - private IntegerFieldEditor addIntegerField(String name, String labelText, - Composite parent) { - IntegerFieldEditor f = new IntegerFieldEditor(name, labelText, parent); - addField(f); - return f; - } - - private BooleanField addBooleanField(String name, String labelText, - Composite parent) { - BooleanField f = new BooleanField(name, labelText, parent); - addField(f); - return f; - } - -// private StringFieldEditor addStringField(String name, String labelText, -// Composite parent) { -// StringFieldEditor f = new StringFieldEditor(name, labelText, parent); -// addField(f); -// return f; -// } - - // protected NumberField addNumberField(String name, String labelText, - // Composite parent) - // { - // NumberField f = new NumberField(name,labelText,parent); - // addField(f); - // return f; - // } - - private ColorFontFieldEditor addFontField(String name, String labelText, - Composite parent) { - ColorFontFieldEditor f = new ColorFontFieldEditor(name, labelText, - parent); - addField(f); - return f; - } - - private static String[][] getLineRoutingLabels() { - return m_lineRoutingLabels; - } - - private static String[][] getLabelPlacementLabels() { - return m_labelPlacementLabels; - } - -// private static void propagateProperty(String property, EditPart part) { -// Iterator iter = part.getChildren().iterator(); -// while (iter.hasNext()) { -// EditPart child = (EditPart) iter.next(); -// Figure fig = (Figure) ((GraphicalEditPart) child).getFigure(); -// GEMPreferences.propagateProperty(property, fig); -// propagateProperty(property, child); -// } -// } - - /** - * @return true if the preference is set to show the introduction - * editor. false otherwise. - */ - public static boolean getShowIntroEditor() - { - IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore(); - return store.getBoolean(SHOW_INTRO_EDITOR); - } - - /** - * @param store - * @param property - * @return the color property for the key 'property' - */ - public static Color getColor(IPreferenceStore store, String property) { - boolean useSystemColors = store.getBoolean(USE_SYSTEM_COLORS); - - Color c = ColorConstants.black; - if (useSystemColors) { - if (GRID_COLOR.equals(property)) - // c = ColorConstants.buttonDarkest; - c = ColorConstants.button; - if (LINE_COLOR.equals(property)) - c = ColorConstants.listForeground; - if (LINE_LABEL_FONT_COLOR.equals(property)) - c = ColorConstants.listForeground; - if (LINE_LABEL_COLOR.equals(property)) - c = ColorConstants.listBackground; - if (CANVAS_COLOR.equals(property)) - c = ColorConstants.listBackground; - if (INPUT_PORT_COLOR.equals(property)) - c = ColorConstants.listForeground; - if (OUTPUT_PORT_COLOR.equals(property)) - c = ColorConstants.listForeground; - if (FIGURE_LABEL_FONT_COLOR.equals(property)) - c = ColorConstants.listForeground; - } else { - // CR392586: resource leaks - RGB rgb = PreferenceConverter.getColor(store, property); - ColorRegistry registry = JFaceResources.getColorRegistry(); - if (registry.get(rgb.toString()) != null) - return registry.get(rgb.toString()); - registry.put(rgb.toString(), rgb); - c = registry.get(rgb.toString()); - } - return c; - } - -// // CR392586: resource leaks -// private static Font getFont(IPreferenceStore store, String property) { -// FontData fd = PreferenceConverter.getFontData(store, property); -// FontRegistry registry = JFaceResources.getFontRegistry(); -// if (!registry.get(fd.toString()).equals(registry.defaultFont())) -// return registry.get(fd.toString()); -// -// registry.put(fd.toString(), new FontData[] {fd}); -// return registry.get(fd.toString()); -// } - -// private static void propagateProperty(String property, Figure fig) { -// IPreferenceStore store = EditorPlugin.getDefault().getPreferenceStore(); -// WindowFigure window = null; -// IconFigure icon = null; -// LinkFigure link = null; -// if (fig instanceof CompoundNodeFigure) { -// window = ((CompoundNodeFigure) fig).getWindowFigure(); -// icon = ((CompoundNodeFigure) fig).getIconFigure(); -// } else if (fig instanceof WindowFigure) -// window = (WindowFigure) fig; -// else if (fig instanceof LinkFigure) -// link = (LinkFigure) fig; -// -// if (property != null && property.equals(USE_SYSTEM_COLORS)) -// // reload all properties - it's easiest -// property = null; -// -// if (property == null || SNAP_TO_GRID.equals(property)) { -// boolean b = store.getBoolean(SNAP_TO_GRID); -// WindowFigure.defaultGridEnabled = b; -// -// if (window != null) -// window.getGridLayer().setVisible(b); -// } -// -// if (property == null || GRID_WIDTH.equals(property) -// || GRID_HEIGHT.equals(property)) { -// Dimension d = new Dimension(store.getInt(GRID_WIDTH), store -// .getInt(GRID_HEIGHT)); -// WindowFigure.defaultGridSpacing = d; -// -// if (window != null) -// window.getGridLayer().setSpacing(d); -// } -// -// if (property == null || GRID_COLOR.equals(property)) { -// Color c = getColor(store, GRID_COLOR); -// WindowFigure.defaultGridColor = c; -// -// if (window != null) -// window.getGridLayer().setForegroundColor(c); -// } -// -// // TODO: since the line router is managed by the EditPart for the -// // container figure, setting the line routing style in the WindowFigure -// // does not change the line routing immediately. The editor must be -// // restarted for line routing to take effect. -// if (property == null || LINE_ROUTING.equals(property)) { -// String s = store.getString(LINE_ROUTING); -// int style; -// if (LINE_ROUTING_MANHATTAN.equals(s)) -// style = WindowFigure.LINE_ROUTING_MANHATTAN; -// else -// style = WindowFigure.LINE_ROUTING_MANUAL; -// -// WindowFigure.defaultLineRoutingStyle = style; -// if (window != null) -// window.setLineRoutingStyle(style); -// } -// -// if (property == null || LINE_WIDTH.equals(property)) { -// int w = store.getInt(LINE_WIDTH); -// LinkFigure.defaultLineWidth = w; -// -// if (link != null) -// link.setLineWidth(w); -// } -// -// if (property == null || LINE_COLOR.equals(property)) { -// Color c = getColor(store, LINE_COLOR); -// LinkFigure.defaultLineColor = c; -// -// if (link != null) -// link.setForegroundColor(c); -// } -// -// if (property == null || SHOW_LINE_LABELS.equals(property)) { -// boolean b = store.getBoolean(SHOW_LINE_LABELS); -// LinkFigure.defaultLabelVisible = b; -// -// if (link != null) -// link.setLabelVisible(b); -// } -// -// if (property == null || LINE_LABEL_FONT.equals(property) -// || LINE_LABEL_FONT_COLOR.equals(property)) { -// // CR392586: resource leaks -// Font f = getFont(store, LINE_LABEL_FONT); -// Color c = getColor(store, LINE_LABEL_FONT_COLOR); -// LinkFigure.defaultFont = f; -// LinkFigure.defaultLabelForeground = c; -// -// if (link != null) { -// link.setFont(f); -// link.setLabelForeground(c); -// } -// } -// -// if (property == null || LINE_LABEL_COLOR.equals(property)) { -// Color c = getColor(store, LINE_LABEL_COLOR); -// LinkFigure.defaultLabelBackground = c; -// -// if (link != null) -// link.setLabelBackground(c); -// } -// -// if (property == null || CANVAS_COLOR.equals(property)) { -// Color c = getColor(store, CANVAS_COLOR); -// WindowFigure.defaultBackgroundColor = c; -// -// if (window != null) -// window.setBackgroundColor(c); -// if (icon != null) -// icon.setBackgroundColor(c); -// } -// -// if (property == null || INPUT_PORT_COLOR.equals(property)) { -// Color c = getColor(store, INPUT_PORT_COLOR); -// InputPortFigure.defaultForegroundColor = c; -// -// if (fig instanceof InputPortFigure) -// fig.setForegroundColor(c); -// } -// -// if (property == null || OUTPUT_PORT_COLOR.equals(property)) { -// Color c = getColor(store, OUTPUT_PORT_COLOR); -// OutputPortFigure.defaultForegroundColor = c; -// -// if (fig instanceof OutputPortFigure) -// fig.setForegroundColor(c); -// } -// -// if (property == null || FIGURE_LABEL_FONT.equals(property) -// || FIGURE_LABEL_FONT_COLOR.equals(property)) { -// // CR392586: resource leaks -// Font f = getFont(store, FIGURE_LABEL_FONT); -// Color c = getColor(store, FIGURE_LABEL_FONT_COLOR); -// IconFigure.defaultFont = f; -// IconFigure.defaultForegroundColor = c; -// WindowFigure.defaultFont = f; -// WindowFigure.defaultForegroundColor = c; -// -// if (window != null) { -// window.setFont(f); -// window.setForegroundColor(c); -// } -// if (icon != null) { -// icon.setFont(f); -// icon.setForegroundColor(c); -// } -// if (fig instanceof IconFigure) { -// fig.setFont(f); -// fig.setForegroundColor(c); -// } -// } -// -// if (property == null || LABEL_PLACEMENT.equals(property)) { -// int placement = PositionConstants.SOUTH; -// String s = store.getString(LABEL_PLACEMENT); -// if (LABEL_PLACEMENT_TOP.equals(s)) -// placement = PositionConstants.NORTH; -// if (LABEL_PLACEMENT_BOTTOM.equals(s)) -// placement = PositionConstants.SOUTH; -// if (LABEL_PLACEMENT_LEFT.equals(s)) -// placement = PositionConstants.WEST; -// if (LABEL_PLACEMENT_RIGHT.equals(s)) -// placement = PositionConstants.EAST; -// IconFigure.defaultTextPlacement = placement; -// -// if (icon != null) -// icon.setTextPlacement(placement); -// if (fig instanceof IconFigure) -// ((IconFigure) fig).setTextPlacement(placement); -// } -// -// Iterator iter = fig.getChildren().iterator(); -// while (iter.hasNext()) { -// Figure child = (Figure) iter.next(); -// propagateProperty(property, child); -// } -// } -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/IBaseFigure.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/IBaseFigure.java deleted file mode 100644 index 16f6834bf..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/IBaseFigure.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.preference; - -import java.util.List; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.swt.graphics.Image; - -/** - * @author Bob - * - * TODO To change the template for this generated type comment go to Window - - * Preferences - Java - Code Style - Code Templates - */ -public interface IBaseFigure extends IFigure { - public abstract void setText(String text); - - public abstract String getText(); - - /* - * CR374981: Long activity labels do not get wrapped or truncated This - * method was added to the IBaseFigure interface to support direct edit of - * figure labels on the canvas. - */ - public abstract Rectangle getTextBounds(); - - public abstract void setIcon(Image image); - - public abstract Image getIcon(); - - public abstract void setToolTipText(String text); - - public abstract String getToolTipText(); - - public abstract void setHighlight(boolean flag); - - public abstract void addDecorator(BaseFigureDecorator decorator); - - public abstract void removeDecorator(); - - public abstract void removeDecorator(int position); - - public abstract List getDecorators(); -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/IContainerFigure.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/IContainerFigure.java deleted file mode 100644 index e627c5312..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/IContainerFigure.java +++ /dev/null @@ -1 +0,0 @@ -/*******************************************************************************
* Copyright (c) 2004, 2006 Sybase, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sybase, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.jst.jsf.facesconfig.ui.preference;
import org.eclipse.draw2d.Layer;
/**
*
* @author bbrodt
*
*
*
* This class extends IBaseFigure by including a layer accessor.
*
*/
public interface IContainerFigure extends IBaseFigure
{
public Layer getLayer(Object key);
}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/IconFigure.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/IconFigure.java deleted file mode 100644 index 9c06a6813..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/IconFigure.java +++ /dev/null @@ -1,399 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.preference; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.draw2d.AncestorListener; -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.Graphics; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.Layer; -import org.eclipse.draw2d.MarginBorder; -import org.eclipse.draw2d.PositionConstants; -import org.eclipse.draw2d.XYLayout; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.Image; - -/** - * And IconFigure consists of a bitmap image with a text label below it. - * - * @author bbrodt - */ -public class IconFigure extends Label implements IBaseFigure { - public static int defaultTextPlacement = PositionConstants.SOUTH; - - public static Font defaultFont = JFaceResources.getFontRegistry().get( - JFaceResources.DEFAULT_FONT); - - public static Color defaultForegroundColor = ColorConstants.black; - - private ArrayList decorators; - - private IconLabel iconLabel = null; - - // CR389070: Figures are abbreviating rule figures names and making them - // unreadable - // New class that implements a separate "floating" label which is NOT - // included in bounds calculations for this IconFigure - private class IconLabel extends Label { - private LabelLocator locator; - - private IconFigure host; - - public IconLabel(IconFigure host, String text) { - super(text); - this.host = host; - locator = new LabelLocator(this); - } - - public IconFigure getHost() { - return host; - } - - public Dimension getPreferredSize(int wHint, int hHing) { - return host.getTextBounds().getSize(); - } - - public void setText(String text) { - super.setText(text); - if (locator != null) - locator.setConstraints(); - } - - public void invalidate() { - if (locator != null) - locator.setConstraints(); - super.invalidate(); - } - } - - // CR389070: Figures are abbreviating rule figures names and making them - // unreadable - // helper class that relocates the IconLabel whenever ancestor is moved or - // added/removed - private class LabelLocator implements AncestorListener { - IconLabel label; - - public LabelLocator(IconLabel label) { - this.label = label; - label.getHost().addAncestorListener(this); - } - - // CR408950: BP Save problems - // fixed icon label refresh problems - private Layer getParentLayer() { - IFigure fig = label.getHost(); - while (fig != null) { - if (fig instanceof Layer) - return (Layer) fig; - fig = fig.getParent(); - } - return null; - } - - public void ancestorAdded(IFigure ancestor) { - Layer layer = getParentLayer(); - if (layer != null && !layer.getChildren().contains(label)) { - layer.add(label); - setConstraints(); - } - } - - public void ancestorMoved(IFigure ancestor) { - setConstraints(); - } - - public void ancestorRemoved(IFigure ancestor) { - // CR400779: GEM minimizing a complex activity sometimes leaves junk - // on the screen - if (label.getParent() != null - && label.getParent().getChildren().contains(label)) - label.getParent().remove(label); - } - - public void setConstraints() { - Layer layer = getParentLayer(); - if (layer != null && layer.getLayoutManager() != null - && layer.getChildren().contains(label)) { - Rectangle r = IconFigure.this.getParent().getBounds().getCopy(); - r.translate(IconFigure.this.getBounds().getLocation()); - r.translate(IconFigure.this.getTextLocation()); - r.width = -1; - r.height = -1; - Rectangle oldr = (Rectangle) layer.getLayoutManager() - .getConstraint(label); - if (oldr == null || oldr.x != r.x || oldr.y != r.y) - layer.setConstraint(label, r); - } - } - } - - /** - * @param name - * @param icon - */ - public IconFigure(String name, Image icon) { - super(name, icon); - setTextPlacement(defaultTextPlacement); - setOpaque(false); - setIcon(icon); - setIconTextGap(0); - setForegroundColor(defaultForegroundColor); - // CR396303: DND in RulePanel does not get correct location if viewer is - // scrolled - setBackgroundColor(ColorConstants.titleGradient); - XYLayout layout = new XYLayout(); - setLayoutManager(layout); - - // CR389070: Figures are abbreviating rule figures names and making them - // unreadable - iconLabel = new IconLabel(this, name); - iconLabel.setFont(getFont()); - } - - // CR389070: Figures are abbreviating rule figures names and making them - // unreadable - public Label getLabel() { - return iconLabel; - } - - public List getDecorators() { - if (decorators == null) - decorators = new ArrayList(); - return decorators; - } - - public Font getFont() { - if (defaultFont == null) - { - defaultFont = JFaceResources.getFontRegistry().get( - JFaceResources.DEFAULT_FONT); - } - - if (getLocalFont() == null) - { - // TODO: replaced a deprecated assignment to font - // with this, but the behaviour is a little different - setFont(defaultFont); - } - - return getLocalFont(); - } - - public void setFont(Font f) { - Font localFont = getLocalFont(); - if (localFont != f) { - iconLabel.setFont(f); - } - super.setFont(f); - } - - public void setVisible(boolean visible) { - super.setVisible(visible); - iconLabel.setVisible(visible); - } - - public void setText(String text) { - super.setText(text); - // CR389070: Figures are abbreviating rule figures names and making them - // unreadable - if (iconLabel != null && iconLabel.isVisible()) { - iconLabel.setText(text); - iconLabel.setFont(getFont()); - // labelLocator.setConstraints(); - } - } - - public void setToolTipText(String text) { - Label toolTipLabel = null; - - if (text != null && text.length() > 0) { - toolTipLabel = new Label(text); - toolTipLabel.setBorder(new MarginBorder(3)); - } - - super.setToolTip(toolTipLabel); - } - - public String getToolTipText() { - if (getToolTip() != null) - return ((Label) getToolTip()).getText(); - return null; - } - - public void setHighlight(boolean flag) { - if (flag) - setOpaque(true); - else - setOpaque(false); - } - - // CR389070: Figures are abbreviating rule figures names and making them - // unreadable - protected Dimension getSubStringTextSize() { - return getTextSize(); - } - - /* - * CR374981: Long activity labels do not get wrapped or truncated We must - * override this so that the label gets truncated - */ - public Dimension getPreferredSize(int wHint, int hHint) { - if (prefSize == null) { - super.getPreferredSize(-1, -1); - prefSize.width = getIconBounds().getSize().width; - Dimension minSize_ = getMinimumSize(wHint, hHint); - if (prefSize.width < minSize_.width) - prefSize.width = minSize_.width; - if (prefSize.height < minSize_.height) - prefSize.height = minSize_.height; - } - return prefSize; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.IFigure#getMinimumSize(int, int) - */ - public Dimension getMinimumSize(int w, int h) { - return new Dimension(8, 8); - } - - public void addDecorator(BaseFigureDecorator decorator) { - removeDecorator(decorator.getPosition()); - getDecorators().add(decorator); - add(decorator); - invalidate(); - } - - public void removeDecorator() { - removeDecorator(BaseFigureDecorator.DEFAULT_DECORATOR_POSITION); - } - - public void removeDecorator(int position) { - Iterator it = getDecorators().iterator(); - while (it.hasNext()) { - BaseFigureDecorator d = (BaseFigureDecorator) it.next(); - if (d.getPosition() == position) { - it.remove(); - remove(d); - invalidate(); - break; - } - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.Label#setTextPlacement(int) - */ - public void setTextPlacement(int where) { - super.setTextPlacement(where); - layout(); - invalidate(); - } - - public void invalidate() { - // CR405873: F111-Error decorator missing - // this was moved to paintFigure() - // placeDecorators(); - super.invalidate(); - } - - private void placeDecorators() { - Point o = getLocation(); - Point p = getIconBounds().getLocation(); - Dimension size = this.getIconBounds().getSize(); - Iterator it = getDecorators().iterator(); - while (it.hasNext()) { - int x = p.x - o.x, y = p.y - o.y; - BaseFigureDecorator decorator = (BaseFigureDecorator) it.next(); - Dimension decoratorSize = decorator.getPreferredSize(); - switch (decorator.getPosition()) { - case (PositionConstants.CENTER | PositionConstants.MIDDLE): - // CR378889: Case of decoration that should be right in the - // middle. - // Had to add a fudge factor because it's not exactly where I - // want it. - int fudge = 4; - y += size.height / 2 - decoratorSize.height / 2 + fudge; - x += size.width / 2 - decoratorSize.width / 2; - break; - case PositionConstants.NORTH: - x += size.width / 2 - decoratorSize.width / 2; - break; - case PositionConstants.NORTH_EAST: - x += size.width - decoratorSize.width; - break; - case PositionConstants.EAST: - x += size.width - decoratorSize.width; - y += size.height / 2 - decoratorSize.height / 2; - break; - case PositionConstants.SOUTH_EAST: - x += size.width - decoratorSize.width; - y += size.height - decoratorSize.height; - break; - case PositionConstants.SOUTH: - x += size.width / 2 - decoratorSize.width / 2; - y += size.height - decoratorSize.height; - break; - case PositionConstants.SOUTH_WEST: - y += size.height - decoratorSize.height; - break; - case PositionConstants.WEST: - y += size.height / 2 - decoratorSize.height / 2; - break; - case PositionConstants.NORTH_WEST: - break; - } - getLayoutManager().setConstraint(decorator, - new Rectangle(x, y, -1, -1)); - } - layout(); - } - - // CR389070: Figures are abbreviating rule figures names and making them - // unreadable - protected void paintFigure(Graphics graphics) { - if (isOpaque()) - super.paintFigure(graphics); - // CR405873: F111-Error decorator missing - placeDecorators(); - Rectangle bounds_ = getBounds(); - graphics.translate(bounds_.x, bounds_.y); - if (getIcon() != null) - graphics.drawImage(getIcon(), getIconLocation()); - if (iconLabel == null || !iconLabel.isVisible()) { - if (!isEnabled()) { - graphics.translate(1, 1); - graphics.setForegroundColor(ColorConstants.buttonLightest); - graphics.drawText(getSubStringText(), getTextLocation()); - graphics.translate(-1, -1); - graphics.setForegroundColor(ColorConstants.buttonDarker); - } - graphics.drawText(getSubStringText(), getTextLocation()); - } - graphics.translate(-bounds_.x, -bounds_.y); - } -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/InputPortFigure.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/InputPortFigure.java deleted file mode 100644 index f58ecc8c2..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/InputPortFigure.java +++ /dev/null @@ -1 +0,0 @@ -/*******************************************************************************
* Copyright (c) 2004, 2006 Sybase, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sybase, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.jst.jsf.facesconfig.ui.preference;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.swt.graphics.Color;
/**
*
* Figure used to draw input ports
*
*/
public class InputPortFigure extends PortFigure
{
public static Color defaultForegroundColor = ColorConstants.black;
public static Color defaultBackgroundColor = ColorConstants.white;
/**
*
*
*
*/
public InputPortFigure()
{
super(FigureConstants.INPUT_PORT);
setBackgroundColor(defaultBackgroundColor);
setForegroundColor(defaultForegroundColor);
}
}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/LinkFigure.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/LinkFigure.java deleted file mode 100644 index 60a9fcad8..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/LinkFigure.java +++ /dev/null @@ -1,337 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.preference; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.LineBorder; -import org.eclipse.draw2d.MarginBorder; -import org.eclipse.draw2d.MidpointLocator; -import org.eclipse.draw2d.PolylineConnection; -import org.eclipse.draw2d.PositionConstants; -import org.eclipse.draw2d.geometry.PointList; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.Image; - -/** - * @author Bob - * - * TODO To change the template for this generated type comment go to Window - - * Preferences - Java - Code Style - Code Templates - */ -public class LinkFigure extends PolylineConnection implements IBaseFigure { - public static Color defaultLineColor = ColorConstants.black; - - public static int defaultLineWidth = 1; - - public static boolean defaultLabelVisible = false; - - public static Color defaultLabelForeground = ColorConstants.black; - - public static Color defaultLabelBackground = ColorConstants.white; - - public static Font defaultFont = JFaceResources.getFontRegistry().get( - JFaceResources.DEFAULT_FONT); - - private LinkLabel label; - - public LinkFigure() { - super(); - setLineWidth(defaultLineWidth); - setForegroundColor(defaultLineColor); - - // BaseFigureDecorator decorator; - // decorator = new - // BaseFigureDecorator(GEMPlugin.getDefault().getGEMImage("delete.gif"),"target",PositionConstants.WEST); - // addDecorator(decorator); - // decorator = new - // BaseFigureDecorator(GEMPlugin.getDefault().getGEMImage("delete.gif"),"target",PositionConstants.EAST); - // addDecorator(decorator); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#setToolTipText() - */ - public void setToolTipText(String text) { - Label toolTip_ = null; - - if (text != null && text.length() > 0) { - toolTip_ = new Label(text); - toolTip_.setBorder(new MarginBorder(3)); - } - - super.setToolTip(toolTip_); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#getToolTipText() - */ - public String getToolTipText() { - if (getToolTip() != null) - return ((Label) getToolTip()).getText(); - return null; - } - - public void setHighlight(boolean flag) { - if (flag) { - setForegroundColor(ColorConstants.titleBackground); - // setLineWidth(defaultLineWidth * 2); - } else { - setForegroundColor(defaultLineColor); - // setLineWidth(defaultLineWidth); - } - } - - public void setSelected(boolean flag) { - if (flag) { - // setForegroundColor(ColorConstants.titleBackground); - setLineWidth(defaultLineWidth * 2); - } else { - // setForegroundColor(defaultLineColor); - setLineWidth(defaultLineWidth); - } - } - - public void setLabelVisible(boolean flag) { - getLabel().setVisible(flag); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#setText() - */ - public void setText(String text) { - if (text == null && text.length() == 0) { - if (label != null) { - remove(label); - label = null; - } - } else { - getLabel().setText(text); - } - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#getText() - */ - public String getText() { - if (label == null) - return null; - return label.getText(); - } - - /* - * CR374981: Long activity labels do not get wrapped or truncated This - * method was added to the IBaseFigure interface to support direct edit of - * figure labels on the canvas. - */ - public Rectangle getTextBounds() { - return label.getTextBounds(); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#setIcon(org.eclipse.swt.graphics.Image) - */ - public void setIcon(Image image) { - getLabel().setIcon(image); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#getIcon() - */ - public Image getIcon() { - return getLabel().getIcon(); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#addDecorator(com.sybase.stf.gem.diagram.editor.figures.BaseFigureDecorator) - */ - public void addDecorator(BaseFigureDecorator decorator) { - int pos = decorator.getPosition(); - if (pos == BaseFigureDecorator.DEFAULT_DECORATOR_POSITION - || pos == PositionConstants.WEST - || pos == PositionConstants.LEFT) { - setTargetDecoration(decorator); - } else if (pos == PositionConstants.EAST - || pos == PositionConstants.RIGHT) { - setSourceDecoration(decorator); - } - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#removeDecorator() - */ - public void removeDecorator() { - removeDecorator(BaseFigureDecorator.DEFAULT_DECORATOR_POSITION); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#removeDecorator(int) - */ - public void removeDecorator(int position) { - if (position == BaseFigureDecorator.DEFAULT_DECORATOR_POSITION) - setTargetDecoration(null); - else - setSourceDecoration(null); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#getDecorators() - */ - public List getDecorators() { - List list = new ArrayList(2); - Object d; - d = getSourceDecoration(); - if (d != null) - list.add(d); - d = getTargetDecoration(); - if (d != null) - list.add(d); - return list; - } - - public LinkLabel getLabel() { - if (label == null) { - label = new LinkLabel(); - add(label, new MidpointLocator(this, 0)); - } - return label; - } - - public void setLabelForeground(Color c) { - getLabel().setForegroundColor(c); - } - - public void setLabelBackground(Color c) { - getLabel().setBackgroundColor(c); - } - - public void setFont(Font f) { - getLabel().setFont(f); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.Shape#setLineWidth(int) - */ - public void setLineWidth(int w) { - getLabel().setBorderWidth(w); - super.setLineWidth(w); - } - - public void setForegroundColor(Color c) { - getLabel().setBorderColor(c); - super.setForegroundColor(c); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.Polyline#setPoints(org.eclipse.draw2d.geometry.PointList) - */ - public void setPoints(PointList points) { - // TODO Auto-generated method stub - super.setPoints(points); - if (label != null) { - int i = getPoints().size() / 2 - 1; - if (i < 0) - i = 0; - if (getLayoutManager() != null) - getLayoutManager().setConstraint(label, - new MidpointLocator(this, i)); - } - } - - public Rectangle getBounds() { - if (bounds == null) { - if (bounds == null) { - bounds = getPoints().getBounds().getExpanded(lineWidth / 2, - lineWidth / 2); - } - // CR382243: Clicking on the node icon selects the connection line - // rather than the node - // NOTE: expanding the bounds to include children (in this case, - // the Link labels) causes problems when the connection line becomes - // short (i.e., when the 2 anchor figures at each end of the - // connection are - // close together) because the bounds of this link figure will be - // greater - // than the actual length of the line. This causes the link figure - // to - // be hit-tested beyond its visual size. - if (getLabel().isVisible()) { - for (int i = 0; i < getChildren().size(); i++) { - IFigure child = (IFigure) getChildren().get(i); - bounds.union(child.getBounds()); - } - } - } - return bounds; - } - - /* - * Helper class for line labels. - */ - public class LinkLabel extends Label { - public LinkLabel() { - setBorder(new LineBorder()); - setOpaque(true); - setForegroundColor(defaultLabelForeground); - setBackgroundColor(defaultLabelBackground); - setFont(defaultFont); - LineBorder border_ = new LineBorder(defaultLineWidth); - setBorder(border_); - border_.setColor(defaultLineColor); - setVisible(defaultLabelVisible); - } - - public void setBorderWidth(int w) { - ((LineBorder) getBorder()).setWidth(w); - } - - public void setBorderColor(Color c) { - ((LineBorder) getBorder()).setColor(c); - } - - protected boolean useLocalCoordinates() { - return false; - } - } -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/ObserveVisibleXYLayout.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/ObserveVisibleXYLayout.java deleted file mode 100644 index 70b72e212..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/ObserveVisibleXYLayout.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.preference; - -import java.util.Iterator; -import java.util.ListIterator; - -import org.eclipse.draw2d.FreeformLayout; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Insets; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; - -/** - * @author Bob Brodt - * - * This is an XY layout that actually observes visiblity of children figures - * when doint its layout. - * - * Apparently there is a bug in the GEF XYLayout class because it does not - * observe visibility. - * - * @see org.eclipse.draw2d.AbstractLayout#isObservingVisibility() - */ -public class ObserveVisibleXYLayout extends FreeformLayout { - protected Dimension calculatePreferredSize(IFigure f, int wHint, int hHint) { - Rectangle rect = new Rectangle(); - ListIterator children = f.getChildren().listIterator(); - while (children.hasNext()) { - IFigure child = (IFigure) children.next(); - // bug fix - if (isObservingVisibility() && !child.isVisible()) - continue; - Rectangle r = (Rectangle) constraints.get(child); - if (r == null) - continue; - - if (r.width == -1 || r.height == -1) { - Dimension preferredSize_ = child.getPreferredSize(r.width, - r.height); - r = r.getCopy(); - if (r.width == -1) - r.width = preferredSize_.width; - if (r.height == -1) - r.height = preferredSize_.height; - } - rect.union(r); - } - Dimension d = rect.getSize(); - Insets insets = f.getInsets(); - return new Dimension(d.width + insets.getWidth(), d.height - + insets.getHeight()).union(getBorderPreferredSize(f)); - } - - public void layout(IFigure parent) { - Iterator children = parent.getChildren().iterator(); - Point offset = getOrigin(parent); - IFigure f; - while (children.hasNext()) { - f = (IFigure) children.next(); - // bug fix - if (isObservingVisibility() && !f.isVisible()) - continue; - Rectangle bounds = (Rectangle) getConstraint(f); - if (bounds == null) - continue; - - if (bounds.width == -1 || bounds.height == -1) { - Dimension preferredSize_ = f.getPreferredSize(bounds.width, - bounds.height); - bounds = bounds.getCopy(); - if (bounds.width == -1) - bounds.width = preferredSize_.width; - if (bounds.height == -1) - bounds.height = preferredSize_.height; - } - bounds = bounds.getTranslated(offset); - f.setBounds(bounds); - } - } -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/OutputPortFigure.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/OutputPortFigure.java deleted file mode 100644 index e6ef854c1..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/OutputPortFigure.java +++ /dev/null @@ -1 +0,0 @@ -/*******************************************************************************
* Copyright (c) 2004, 2006 Sybase, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sybase, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.jst.jsf.facesconfig.ui.preference;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.swt.graphics.Color;
/**
*
*/
public class OutputPortFigure extends PortFigure
{
public static Color defaultForegroundColor = ColorConstants.black;
public static Color defaultBackgroundColor = ColorConstants.white;
/**
*
*
*
*/
public OutputPortFigure()
{
super(FigureConstants.OUTPUT_PORT);
setBackgroundColor(defaultBackgroundColor);
setForegroundColor(defaultForegroundColor);
}
}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/PortConnectionAnchor.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/PortConnectionAnchor.java deleted file mode 100644 index 02ef0f474..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/PortConnectionAnchor.java +++ /dev/null @@ -1 +0,0 @@ -/*******************************************************************************
* Copyright (c) 2004, 2006 Sybase, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sybase, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.jst.jsf.facesconfig.ui.preference;
import java.util.Iterator;
import java.util.Vector;
import org.eclipse.draw2d.AbstractConnectionAnchor;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.PolylineConnection;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.PrecisionPoint;
import org.eclipse.draw2d.geometry.Rectangle;
/**
*
*/
public class PortConnectionAnchor extends AbstractConnectionAnchor
{
// CR386077: SplitActivity True and False outputs switch positions based on
// their targets
protected int orientation = PositionConstants.NONE;
/**
*
*
*
*/
public PortConnectionAnchor()
{
super();
// TODO Auto-generated constructor stub
}
/**
*
* @param owner
*
*/
public PortConnectionAnchor(IFigure owner)
{
super(owner);
}
// CR386077: SplitActivity True and False outputs switch positions based on
// their targets
public int getOrientation()
{
return orientation;
}
public void setOrientation(int o)
{
orientation = o;
((PortFigure) getOwner()).setOrientation(orientation);
}
/*
*
* (non-Javadoc)
*
*
*
* @see org.eclipse.draw2d.ConnectionAnchor#getLocation(org.eclipse.draw2d.geometry.Point)
*
*/
public Point getLocation(Point arg0)
{
PortFigure portFigure = (PortFigure) getOwner();
Point result = new Point(0, 0);
Rectangle r = portFigure.getBounds();
switch (portFigure.getOrientation())
{
case PositionConstants.NORTH:
result = new PrecisionPoint(r.x + r.width / 2, r.y);
break;
case PositionConstants.SOUTH:
result = new PrecisionPoint(r.x + r.width / 2, r.y + r.height);
break;
case PositionConstants.WEST:
result = new PrecisionPoint(r.x, r.y + r.height / 2);
break;
case PositionConstants.EAST:
result = new PrecisionPoint(r.x + r.width, r.y + r.height / 2);
break;
}
portFigure.translateToAbsolute(result);
return result;
}
public Vector getConnections()
{
Vector list = new Vector();
Iterator it = listeners.iterator();
while (it.hasNext())
{
Object listener = it.next();
if (listener instanceof PolylineConnection)
list.add(listener);
}
return list;
}
}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/PortFigure.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/PortFigure.java deleted file mode 100644 index 3444ffbc8..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/PortFigure.java +++ /dev/null @@ -1 +0,0 @@ -/*******************************************************************************
* Copyright (c) 2004, 2006 Sybase, Inc. and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sybase, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.jst.jsf.facesconfig.ui.preference;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Insets;
import org.eclipse.draw2d.geometry.PointList;
import org.eclipse.draw2d.geometry.Rectangle;
/**
*
* Provides the base implementation for all the port figures.
*
*/
public class PortFigure extends Figure
{
private boolean showBox = false;
private boolean showArrow = true;
// orientation is one of the four positions constants
// NORTH, SOUTH, EAST or WEST and indicates on which side
// of the parent figure the connection anchor figure is
// located.
private int orientation = PositionConstants.WEST;
// type is the port type; either input or output
private int type = FigureConstants.INPUT_PORT;
/**
*
* Construct a port figure.
*
*/
public PortFigure(int type)
{
super();
this.type = type;
setOpaque(false);
}
/**
*
* @param b
*
*/
public void setBoxVisible(boolean b)
{
showBox = b;
repaint();
}
public void setArrowVisible(boolean b)
{
showArrow = b;
repaint();
}
/**
*
* @return Returns the type.
*
*/
public int getType()
{
return type;
}
/**
*
* @param type
* The type to set.
*
*/
public void setType(int type)
{
this.type = type;
}
public void setOrientation(int o)
{
orientation = o;
}
public int getOrientation()
{
return orientation;
}
public void setToolTipText(String text)
{
setToolTip(new Label(text));
}
public String getToolTipText()
{
IFigure fig = getToolTip();
if (fig instanceof Label)
return ((Label) fig).getText();
return null;
}
/*
*
* (non-Javadoc)
*
*
*
* @see org.eclipse.draw2d.IFigure#paint(org.eclipse.draw2d.Graphics)
*
*/
public void paintFigure(Graphics g)
{
super.paintFigure(g);
Rectangle bounds_ = getBounds();
g.setForegroundColor(getForegroundColor());
if (showBox)
{
// draw outer rectangle
g.setBackgroundColor(getBackgroundColor());
g.fillRectangle(getBounds().getCropped(new Insets(0, 1, 1, 0)));
Rectangle r = getBounds().getExpanded(-1, -1).getTranslated(0, -1);
r.height += 1;
g.drawRectangle(r);
}
if (showArrow)
{
// draw arrowhead
g.setBackgroundColor(getForegroundColor());
PointList pts = new PointList();
if (type == FigureConstants.INPUT_PORT)
{
switch (orientation)
{
case PositionConstants.NORTH:
pts.addPoint(bounds_.getTopLeft());
pts.addPoint(bounds_.getTopRight());
pts.addPoint(bounds_.getBottom());
pts.addPoint(bounds_.getTopLeft());
break;
case PositionConstants.SOUTH:
pts.addPoint(bounds_.getBottomLeft());
pts.addPoint(bounds_.getTop());
pts.addPoint(bounds_.getBottomRight());
pts.addPoint(bounds_.getBottomLeft());
break;
case PositionConstants.EAST:
pts.addPoint(bounds_.getTopRight());
pts.addPoint(bounds_.getBottomRight());
pts.addPoint(bounds_.getLeft());
pts.addPoint(bounds_.getTopRight());
break;
case PositionConstants.WEST:
pts.addPoint(bounds_.getTopLeft());
pts.addPoint(bounds_.getRight());
pts.addPoint(bounds_.getBottomLeft());
pts.addPoint(bounds_.getTopLeft());
break;
}
}
else
{
switch (orientation)
{
case PositionConstants.NORTH:
pts.addPoint(bounds_.getBottomLeft());
pts.addPoint(bounds_.getTop());
pts.addPoint(bounds_.getBottomRight());
pts.addPoint(bounds_.getBottomLeft());
break;
case PositionConstants.SOUTH:
pts.addPoint(bounds_.getTopLeft());
pts.addPoint(bounds_.getTopRight());
pts.addPoint(bounds_.getBottom());
pts.addPoint(bounds_.getTopLeft());
break;
case PositionConstants.EAST:
pts.addPoint(bounds_.getTopLeft());
pts.addPoint(bounds_.getRight());
pts.addPoint(bounds_.getBottomLeft());
pts.addPoint(bounds_.getTopLeft());
break;
case PositionConstants.WEST:
pts.addPoint(bounds_.getTopRight());
pts.addPoint(bounds_.getBottomRight());
pts.addPoint(bounds_.getLeft());
pts.addPoint(bounds_.getTopRight());
break;
}
}
g.fillPolygon(pts);
g.drawPolyline(pts);
}
}
/*
*
* (non-Javadoc)
*
*
*
* @see org.eclipse.draw2d.IFigure#getPreferredSize(int, int)
*
*/
public Dimension getPreferredSize(int wHint, int hHint)
{
Dimension d = new Dimension(FigureConstants.PORT_SIDE,
FigureConstants.PORT_SIDE);
// CR389070: Figures are abbreviating rule figures names and making them
// unreadable
// anchor size is now determined by the size of the owning figure icon
if (getParent() instanceof BaseNodeFigure)
{
IBaseFigure fig = ((BaseNodeFigure) getParent()).getBaseFigure();
if (fig != null && fig.getIcon() != null)
{
org.eclipse.swt.graphics.Rectangle r = fig.getIcon()
.getBounds();
if (r.width < 40)
d.width /= 2;
if (r.height < 40)
d.height /= 2;
}
}
return d;
}
}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/PreferenceMessages.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/PreferenceMessages.java deleted file mode 100644 index 2d7f25237..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/PreferenceMessages.java +++ /dev/null @@ -1,202 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - - -package org.eclipse.jst.jsf.facesconfig.ui.preference; - -import org.eclipse.osgi.util.NLS; - -/** - * The NLS message manager for PreferenceMessages - * - */ -public final class PreferenceMessages extends NLS { - - private static final String BUNDLE_NAME = "org.eclipse.jst.jsf.facesconfig.ui.preference.PreferenceMessages"; - - private PreferenceMessages() { - // Do not instantiate - } - - static { - NLS.initializeMessages(BUNDLE_NAME, PreferenceMessages.class); - } - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_UseSystemColors; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_BackgroundColor; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_Canvas; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_GridHeight; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_GridLineColor; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_GridWidth; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_IconLabelFont; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_IconGroup; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_InputPortColor; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_OutputPortColor; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_LineGroup; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_LineColor; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_ShowLineLabels; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_LineLabelColor; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_LineLabelFont; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_LineRouting; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_LineWidth; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_SnapToGeometry; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_SnapToGrid; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_UndoStackSize; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferences_LABEL_Direct; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferences_LABEL_Manhattan; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferences_LABEL_Manual; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_LabelPlacement; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferences_LABEL_Top; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferences_LABEL_Bottom; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferences_LABEL_Left; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferences_LABEL_Right; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferenceTab_LABEL_IconSize; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferences_LABEL_Small; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferences_LABEL_Medium; - - /** - * see PreferenceMessages.properties - */ - public static String CanvasPreferences_LABEL_Large; - - /** - * label property for check box that selects whether or not - * the introduction section editor should be loaded. - */ - public static String EditorPreferences_LABEL_ShowIntroEditor; - - public static String GEMPreferences_description; - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/PreferenceMessages.properties b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/PreferenceMessages.properties deleted file mode 100644 index a65ffd1ec..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/PreferenceMessages.properties +++ /dev/null @@ -1,47 +0,0 @@ -############################################################################### -# Copyright (c) 2001, 2007 Oracle Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Oracle Corporation - initial API and implementation -############################################################################### -# -# Appearance preference labels -# -CanvasPreferenceTab_LABEL_UseSystemColors=Use System colors -EditorPreferences_LABEL_ShowIntroEditor=Show Introduction Tab (open editors must be reloaded to take effect) -CanvasPreferenceTab_LABEL_BackgroundColor=Background color: -CanvasPreferenceTab_LABEL_Canvas=Canvas -CanvasPreferenceTab_LABEL_GridHeight=Grid height: -CanvasPreferenceTab_LABEL_GridLineColor=Grid color: -CanvasPreferenceTab_LABEL_GridWidth=Grid width: -CanvasPreferenceTab_LABEL_IconLabelFont=Label font: -CanvasPreferenceTab_LABEL_IconGroup=Icons -CanvasPreferenceTab_LABEL_InputPortColor=Input Port color: -CanvasPreferenceTab_LABEL_OutputPortColor=Output Port color: -CanvasPreferenceTab_LABEL_LineGroup=Connection Lines -CanvasPreferenceTab_LABEL_LineColor=Line color: -CanvasPreferenceTab_LABEL_ShowLineLabels=Show labels -CanvasPreferenceTab_LABEL_LineLabelColor=Label color: -CanvasPreferenceTab_LABEL_LineLabelFont=Label font: -CanvasPreferenceTab_LABEL_LineRouting=Line Routing: -CanvasPreferenceTab_LABEL_LineWidth=Line width: -CanvasPreferenceTab_LABEL_SnapToGeometry=Snap to geometry -CanvasPreferenceTab_LABEL_SnapToGrid=Snap to grid -CanvasPreferenceTab_LABEL_UndoStackSize="Undo\" stack size: -CanvasPreferences_LABEL_Direct=Direct -CanvasPreferences_LABEL_Manhattan=Manhattan -CanvasPreferences_LABEL_Manual=Manual -CanvasPreferenceTab_LABEL_LabelPlacement=Label Placement: -CanvasPreferences_LABEL_Top=Top -CanvasPreferences_LABEL_Bottom=Bottom -CanvasPreferences_LABEL_Left=Left -CanvasPreferences_LABEL_Right=Right -CanvasPreferenceTab_LABEL_IconSize=Icon Size: -CanvasPreferences_LABEL_Small=Small -CanvasPreferences_LABEL_Medium=Medium -CanvasPreferences_LABEL_Large=Large -GEMPreferences_description=Preferences for the graphical page of FacesConfig editor. diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/PrintedPageLayer.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/PrintedPageLayer.java deleted file mode 100644 index 5bd3f1cba..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/PrintedPageLayer.java +++ /dev/null @@ -1,169 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.preference; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.draw2d.Figure; -import org.eclipse.draw2d.FreeformLayer; -import org.eclipse.draw2d.FreeformLayeredPane; -import org.eclipse.draw2d.RectangleFigure; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.LayerConstants; - -/** - * This is a printable layer that draws page outline tiles enclosing all of the - * printable child figures. The page outlines represent complete pages as they - * would appear if they were printed on dead trees, thus the pageSize set on - * this layer should be the currently selected printer's page resolution. - * - * The reason this needs to be added to the printable layers is so that it will - * show up in the content outline viewer. - */ -public class PrintedPageLayer extends FreeformLayer { - // our layer name - public static final String PRINTED_PAGE_LAYER = "Printed Page"; - - // the size of the page tiles (this should be the printer's resolution) - protected Dimension pageSize = new Dimension(850, 1100); - - // the WindowFigure that owns this layer - private final WindowFigure host; - - // flag to lock out multiple calls to setFreeformBounds() when adding - // and removing PrintedPageFigures. - private boolean busy; - - // A simple page outline figure. We can get fancy later with turned-up - // dogears, page numbers, titles and whatnot... - class PrintedPageFigure extends RectangleFigure { - PrintedPageFigure() { - super(); - setFill(false); - setOutline(true); - setLineWidth(1); - } - } - - public PrintedPageLayer(WindowFigure figure) { - super(); - this.host = figure; - } - - protected PrintedPageFigure createPage(int x, int y) { - PrintedPageFigure page = new PrintedPageFigure(); - page.setBounds(new Rectangle(x, y, pageSize.width, pageSize.height)); - return page; - } - - /** - * Sets the page width and height. This should be the currently selected - * printer's page size. - * - * @param d - */ - public void setPageSize(Dimension d) { - pageSize = d.getCopy(); - } - - /** - * @see org.eclipse.draw2d.FreeformFigure#setFreeformBounds(Rectangle) - */ - public void setFreeformBounds(Rectangle bounds) { - if (!busy && getParent() instanceof FreeformLayeredPane - && pageSize.width > 0 && pageSize.height > 0) { - busy = true; - - // build the new printing layer extent by looking at only the - // contents of the Primary, Connection and Feedback layers - Rectangle b; - FreeformLayer layer; - layer = (FreeformLayer) host.getLayer(LayerConstants.PRIMARY_LAYER); - b = layer.getFreeformExtent().getCopy(); - layer = (FreeformLayer) host - .getLayer(LayerConstants.CONNECTION_LAYER); - b = b.union(layer.getFreeformExtent()); - layer = (FreeformLayer) host - .getLayer(LayerConstants.FEEDBACK_LAYER); - b = b.union(layer.getFreeformExtent()); - - // calculate x and y for the page tiles - int x = 0, y = 0; - if (b.x < 0) { - while (x > b.x) - x -= pageSize.width; - } else { - while (x + pageSize.width < b.x) - x += pageSize.width; - } - if (b.y < 0) { - while (y > b.y) - y -= pageSize.height; - } else { - while (y + pageSize.height < b.y) - y += pageSize.height; - } - - // get list of pagefigures that intersect the new extent - // and a list of those that don't - List keepers = new ArrayList(); - List trash = new ArrayList(); - Iterator iter = getChildren().iterator(); - while (iter.hasNext()) { - Figure child = (Figure) iter.next(); - if (child.getBounds().intersects(b)) - keepers.add(child); - else - trash.add(child); - } - - // calculate width and height - int w = 0, h = 0; - while (x + w < b.x + b.width) - w += pageSize.width; - while (y + h < b.y + b.height) - h += pageSize.height; - - // determine the required pagefigures - for (int xi = x; xi < x + w; xi += pageSize.width) { - for (int yi = y; yi < y + h; yi += pageSize.height) { - boolean found = false; - iter = keepers.iterator(); - while (iter.hasNext()) { - Figure child = (Figure) iter.next(); - Point p = child.getBounds().getLocation(); - if (p.x == xi && p.y == yi) { - found = true; - break; - } - } - if (!found) { - // add the new page - add(createPage(xi, yi)); - } - } - } - - // remove all the old pages - iter = trash.iterator(); - while (iter.hasNext()) - remove((Figure) iter.next()); - - busy = false; - } - super.setFreeformBounds(bounds); - } -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/RectangleList.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/RectangleList.java deleted file mode 100644 index 068c89f4d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/RectangleList.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.preference; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.draw2d.Figure; -import org.eclipse.draw2d.geometry.Rectangle; - -public class RectangleList extends Figure { - protected List rectangles = new ArrayList(); - - public RectangleList() { - // ?? - } - - public void addRectangle(int x1, int y1, int x2, int y2) { - rectangles.add(new Rectangle(x1, y1, x2 - x1, y2 - y1)); - } - - public List getRectangles() { - return rectangles; - } -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/TabbedTitleBarBorder.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/TabbedTitleBarBorder.java deleted file mode 100644 index 81114276d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/TabbedTitleBarBorder.java +++ /dev/null @@ -1,463 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.preference; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.runtime.ListenerList; -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.FigureUtilities; -import org.eclipse.draw2d.Graphics; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.MouseEvent; -import org.eclipse.draw2d.MouseListener; -import org.eclipse.draw2d.SchemeBorder; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Insets; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.widgets.Composite; - -public class TabbedTitleBarBorder extends SchemeBorder { - // private int state = CompoundFigureListener.RESTORED; - - private IFigure parent; - - private ListenerList listenerList; - - private List tabList; - - private int currentTab; - - private Font font; - - private boolean visible = true; - - // from TitleBarBorder: - private Color textColor = ColorConstants.black; - - private Color bgColor = ColorConstants.menuBackground; - - private Insets insets; - - private Insets padding = new Insets(2, 2, 2, 2); - - /** - * Constructs a TitleBarBorder with its label set to the name of this class. - * - * @since 2.0 - */ - public TabbedTitleBarBorder(final IFigure parent) { - super(SCHEMES.LOWERED); - - this.parent = parent; - - parent.addMouseListener(new MouseListener() { - public void mousePressed(MouseEvent me) { - Insets padding_ = getPadding(); - Point mp = me.getLocation(); - mp.x -= padding_.left; - mp.y -= padding_.top + 3; // 3==width of the outer border - Point pp = parent.getBounds().getLocation(); - Rectangle tr = new Rectangle(pp.x, pp.y, 0, 0); - //int activeIndex = -1; - - for (int i = 0; i < getTabList().size(); ++i) { - Tab t = (Tab) tabList.get(i); - Dimension d = t.getTextExtents(); - d.height += padding_.top + padding_.bottom; - d.width += padding_.left; - tr.setSize(d); - if (tr.contains(mp)) { - setCurrentTab(i); - return; - } - tr.x += d.width; - } - } - - public void mouseReleased(MouseEvent me) { - // do nothing: not handling release - } - - public void mouseDoubleClicked(MouseEvent me) { - // do nothing: not handling release - } - }); - } - - protected List getTabList() { - if (tabList == null) - tabList = new ArrayList(); - return tabList; - } - - public int addTab(String text) { - getTabList().add(new Tab(text)); - return getTabList().size() - 1; - } - - public void removeTab(int index) { - if (index >= 0 && index < getTabList().size()) { - tabList.remove(index); - if (index >= tabList.size()) - index = tabList.size() - 1; - setCurrentTab(index); - } - } - - public void setCurrentTab(int newIndex) { - if (newIndex >= 0 && newIndex < getTabList().size()) { - Tab newTab = (Tab) tabList.get(newIndex); - int oldIndex = -1; - for (int i = 0; i < tabList.size(); ++i) { - Tab t = (Tab) tabList.get(i); - if (t.isActive()) { - oldIndex = i; - t.setActive(false); - break; - } - } - newTab.setActive(true); - if (parent != null) { - parent.invalidate(); - parent.repaint(); - } - currentTab = newIndex; - fireTabChanged(oldIndex, newIndex); - } - } - - public int getCurrentTab() { - return currentTab; - } - - public Object getContents(int index) { - if (index >= 0 && index < getTabList().size()) - return ((Tab) tabList.get(index)).getContents(); - return null; - } - - public void setContents(int index, Object contents) { - if (index >= 0 && index < getTabList().size()) - ((Tab) tabList.get(index)).setContents(contents); - } - - public void addTabbedWindowListener(WindowFigureListener listener) { - if (listenerList == null) - listenerList = new ListenerList(ListenerList.IDENTITY); - listenerList.add(listener); - } - - public void removeTabbedWindowListener(WindowFigureListener listener) { - if (listenerList != null) - listenerList.remove(listener); - } - - public Object[] getListeners() { - return listenerList.getListeners(); - } - - protected void fireTabChanged(int oldIndex, int newIndex) { - Object l[] = listenerList.getListeners(); - for (int i = 0; i < l.length; ++i) { - if (l[i] instanceof WindowFigureListener) - ((WindowFigureListener) l[i]).tabChanged(oldIndex, newIndex); - } - } - - /** - * @return Returns the font. - */ - public Font getFont() { - if (font == null) { - font = parent.getFont(); - if (font == null) - font = JFaceResources.getFontRegistry().get( - JFaceResources.DEFAULT_FONT); - } - return font; - } - - /** - * @param font - * The font to set. - */ - public void setFont(Font font) { - this.font = font; - invalidate(); - } - - /** - * @return Returns the insets. - */ - public Insets getInsets() { - return insets; - } - - public void setTextColor(Color c) { - textColor = c; - } - - public Color getTextColor() { - return textColor; - } - - public void setBackgroundColor(Color c) { - bgColor = c; - } - - public Color getBackgroundColor() { - return bgColor; - } - - public void setPadding(Insets p) { - padding = p; - invalidate(); - } - - public Insets getPadding() { - return padding; - } - - public void setLabel(String text) { - setLabel(currentTab, text); - } - - public void setLabel(int index, String text) { - if (index >= 0 && index < getTabList().size()) - ((Tab) tabList.get(index)).setLabel(text); - } - - public String getLabel() { - return getLabel(currentTab); - } - - public String getLabel(int index) { - if (index >= 0 && index < getTabList().size()) - return ((Tab) tabList.get(index)).getLabel(); - return ""; - } - - public IFigure getParent() { - return parent; - } - - public void invalidate() { - insets = null; - for (int i = 0; i < getTabList().size(); ++i) { - Tab t = (Tab) tabList.get(i); - t.invalidate(); - } - } - - public Dimension getTextExtents(IFigure f) { - Dimension d = new Dimension(0, 0); - for (int i = 0; i < getTabList().size(); ++i) { - Tab t = (Tab) tabList.get(i); - if (d.height == 0) - d = t.getTextExtents(); - else - d.width += t.getTextExtents().width; - } - return d; - } - - /** - * Sets the min/max buttons visible - * - * @param flag - - * if true, buttons are made visible. - */ - public void setVisible(boolean flag) { - visible = flag; - } - - /** - * Calculates and returns the Insets for this border. - * - * @param figure - * the figure on which Insets calculations are based - * @return the calculated Insets - * @since 2.0 - */ - protected Insets calculateInsets(IFigure figure) { - insets = new Insets(super.getInsets(figure)); - insets.top = getTextExtents(figure).height; - return insets; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.Border#getInsets(org.eclipse.draw2d.IFigure) - */ - public Insets getInsets(IFigure figure) { - if (insets == null) - calculateInsets(figure); - return insets; - } - - /** - * @see org.eclipse.draw2d.Border#paint(IFigure, Graphics, Insets) - */ - public void paint(IFigure figure, Graphics g, Insets in) { - if (!visible) - return; - - Insets is = new Insets(in); - getInsets(figure); - is.top += insets.top; - super.paint(figure, g, is); - // Insets insets = getInsets(pane); - // Insets padding = getPadding(); - // Insets in = new Insets(figureInsets); - // in.top += insets.top; - // super.paint(pane, g, in); - - tempRect.setBounds(getPaintRectangle(figure, in)); - Rectangle r = tempRect; - r.height = Math.min(r.height, getTextExtents(figure).height); - - g.clipRect(r); - g.setBackgroundColor(getBackgroundColor()); - g.fillRectangle(r); - int x = r.x; - int y = r.y; - - Iterator iter = getTabList().iterator(); - while (iter.hasNext()) { - Tab t = (Tab) iter.next(); - t.paint(g, figure, x, y); - x += t.getTextExtents().width; - } - - g.setBackgroundColor(getBackgroundColor()); - } - - public Dimension getMinimumSize(int wHint, int hHint) { - Dimension d = getTextExtents(parent); - getInsets(parent); - d.expand(insets.left + insets.right, insets.top + insets.bottom); - // add enough width for the min/max buttons - // d.width += minButton.getSize().width + maxButton.getSize().width; - return d; - } - - private class Tab { - private String label = ""; - - private Object contents = null; - - private Dimension textExtents; - - private boolean active; - - public Tab(String text) { - this.label = text; - } - - public void setContents(Object contents) { - this.contents = contents; - } - - public Object getContents() { - return contents; - } - - public void setActive(boolean active) { - this.active = active; - } - - public boolean isActive() { - return active; - } - - public String getLabel() { - return label; - } - - public void setLabel(String text) { - if (text == null) - this.label = ""; - else - this.label = text; - textExtents = null; - } - - public Dimension calculateTextExtents() { - textExtents = FigureUtilities.getTextExtents(label == null ? "W" - : label, getFont()); - textExtents.width += getPadding().getWidth(); - textExtents.height += getPadding().getHeight(); - return textExtents; - } - - public Dimension getTextExtents() { - if (textExtents == null) - calculateTextExtents(); - return textExtents.getCopy(); - } - - public void invalidate() { - textExtents = null; - } - - public void paint(Graphics g, IFigure f, int x, int y) { - if (contents instanceof Composite) { - return; - } - IFigure pane = (IFigure) contents; - getTextExtents(); - - Insets p = getPadding(); - int w = textExtents.width; - int h = textExtents.height; - int radius = Math.max(p.getWidth(), p.getHeight()) + 2; - - // CR408950: BP Save problems - // fixed icon label refresh problems - if (getTabList().size() > 1) { - // only draw tabList if there are more than 1 - if (active) - g.setBackgroundColor(pane == null ? ColorConstants.white - : pane.getBackgroundColor()); - else - g.setBackgroundColor(getBackgroundColor()); - - --w; - g.setForegroundColor(active ? ColorConstants.buttonDarkest - : ColorConstants.buttonDarker); - // g.setForegroundColor(ColorConstants.red); - g.drawRectangle(x, y + h / 2, w, h); - // g.setBackgroundColor(ColorConstants.green); - g.fillRoundRectangle(new Rectangle(x, y, w, h), radius, radius); - // g.setForegroundColor(ColorConstants.blue); - g.drawRoundRectangle(new Rectangle(x, y, w, h), radius, radius); - // g.setBackgroundColor(ColorConstants.yellow); - g.fillRectangle(x + 1, y + h / 2, w - 1, h); - } else - g.setBackgroundColor(getBackgroundColor()); - - g.setFont(getFont()); - g.setForegroundColor(getTextColor()); - if (label != null) - g.drawString(label, x + padding.left + 1, y + padding.top); - } - } -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/TabbedWindowBorder.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/TabbedWindowBorder.java deleted file mode 100644 index 9e8ce1356..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/TabbedWindowBorder.java +++ /dev/null @@ -1,184 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.preference; - -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.FigureUtilities; -import org.eclipse.draw2d.FrameBorder; -import org.eclipse.draw2d.Graphics; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.SchemeBorder; -import org.eclipse.draw2d.geometry.Insets; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.widgets.Composite; - -public class TabbedWindowBorder extends FrameBorder { - private boolean isVisible = true; - - // CR392586: resource leaks - private static MySchemeBorder normalBorder = new MySchemeBorder( - new MySchemeBorder.MyScheme( - new Color[] { ColorConstants.button, - ColorConstants.buttonLightest, - ColorConstants.button }, - new Color[] { ColorConstants.buttonDarkest, - ColorConstants.buttonDarker, ColorConstants.button })); - - // CR392586: resource leaks - private static MySchemeBorder highlightBorder = new MySchemeBorder( - new MySchemeBorder.MyScheme(new Color[] { - FigureUtilities.lighter(ColorConstants.titleBackground), - ColorConstants.titleBackground, - FigureUtilities.darker(ColorConstants.titleBackground) }, - new Color[] { - FigureUtilities - .darker(ColorConstants.titleGradient), - ColorConstants.titleGradient, - FigureUtilities - .lighter(ColorConstants.titleGradient) })); - - public static class MySchemeBorder extends SchemeBorder { - public static class MyScheme extends SchemeBorder.Scheme { - public MyScheme(Color[] highlight, Color[] shadow) { - super(highlight, shadow); - } - - public Color[] getHighlight() { - return super.getHighlight(); - } - - public Color[] getShadow() { - return super.getHighlight(); - } - } - - MySchemeBorder(MyScheme scheme) { - super(scheme); - } - - public MyScheme getMyScheme() { - return (MyScheme) super.getScheme(); - } - - /** - * @see org.eclipse.draw2d.Border#paint(IFigure, Graphics, Insets) - */ - public void paint(Composite comp, GC gc, Insets insets) { - Color[] tl = getMyScheme().getHighlight(); - Color[] br = getMyScheme().getShadow(); - paint(comp, gc, insets, tl, br); - } - - /** - * Paints the border using the information in the set Scheme and the - * inputs given. Side widths are determined by the number of colors in - * the Scheme for each side. - * @param comp - * the composit whose rect should be used for the inset bounds - * @param gc - * the graphics object - * @param insets - * the insets - * @param tl - * the highlight (top/left) colors - * @param br - * the shadow (bottom/right) colors - */ - protected void paint(Composite comp, GC gc, Insets insets, Color[] tl, - Color[] br) { - org.eclipse.swt.graphics.Rectangle rect = comp.getBounds(); - - gc.setLineWidth(1); - gc.setLineStyle(SWT.LINE_SOLID); - // TODO: deprecated with no obvious replacement: - gc.setXORMode(false); - - int top = rect.y - insets.top; - int left = rect.x - insets.left; - int bottom = rect.y + rect.height + insets.bottom; - int right = rect.x + rect.width + insets.right; - gc.setClipping(new org.eclipse.swt.graphics.Rectangle(left, top, - right - left, bottom - top)); - - Color color = ColorConstants.red; - gc.setForeground(color); - gc.drawLine(left, top, right, bottom); - - for (int i = 0; i < br.length; i++) { - // color = br[i]; - gc.setForeground(color); - gc.drawLine(right - i, bottom - i, right - i, top + i); - gc.drawLine(right - i, bottom - i, left + i, bottom - i); - } - - right--; - bottom--; - - for (int i = 0; i < tl.length; i++) { - // color = tl[i]; - gc.setForeground(color); - gc.drawLine(left + i, top + i, right - i, top + i); - gc.drawLine(left + i, top + i, left + i, bottom - i); - } - color.dispose(); - } - } - - public TabbedWindowBorder(IFigure parent) { - // apparently paint() gets called before createBorders() has had - // a chance to create the borders, so we just create them here - inner = new TabbedTitleBarBorder(parent); - outer = normalBorder; - } - - public void setVisible(boolean flag) { - if (isVisible != flag) { - isVisible = flag; - ((TabbedTitleBarBorder) inner).setVisible(flag); - if (flag) - ((TabbedTitleBarBorder) inner).getParent().repaint(); - } - } - - public void setHighlight(boolean flag) { - if (flag) - outer = highlightBorder; - else - outer = normalBorder; - ((TabbedTitleBarBorder) inner).getParent().repaint(); - } - - protected void createBorders() { - // TODO: NOTE: this is overriding default border creation - } - - public void paint(IFigure figure, Graphics g, Insets insets) { - if (isVisible) { - if (comp != null) { - GC gc = new GC(comp); - paint(comp, gc, insets); - gc.dispose(); - } else - super.paint(figure, g, insets); - } - } - - private Composite comp; - - public void paint(Composite comp_, GC gc, Insets insets) { - this.comp = comp_; - if (isVisible) - ((MySchemeBorder) outer).paint(comp_, gc, insets); - } -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/TitleBarButton.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/TitleBarButton.java deleted file mode 100644 index a30063e40..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/TitleBarButton.java +++ /dev/null @@ -1,216 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.preference; - -import java.util.Iterator; - -import org.eclipse.draw2d.ActionEvent; -import org.eclipse.draw2d.ActionListener; -import org.eclipse.draw2d.Button; -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.Cursors; -import org.eclipse.draw2d.Graphics; -import org.eclipse.draw2d.MouseEvent; -import org.eclipse.draw2d.MouseMotionListener; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.swt.graphics.Image; - -public class TitleBarButton extends Button { - boolean state = false; - - Image uncheckedImage; - - Image checkedImage; - - Image uncheckedHiliteImage; - - Image checkedHiliteImage; - - RectangleList uncheckedRects; - - RectangleList checkedRects; - - boolean hilite = false; - - public TitleBarButton(Image image) { - this(image, null, null, null); - } - - public TitleBarButton(Image unchecked, Image uncheckedHilite, - Image checked, Image checkedHilite) { - super(); - uncheckedImage = unchecked; - if (uncheckedHilite == null) - uncheckedHiliteImage = unchecked; - else - uncheckedHiliteImage = uncheckedHilite; - if (checked == null) - checkedImage = unchecked; - else - checkedImage = checked; - if (checkedHilite == null) - checkedHiliteImage = unchecked; - else - checkedHiliteImage = checkedHilite; - initialize(); - } - - public TitleBarButton(RectangleList rects) { - super(); - uncheckedRects = rects; - initialize(); - } - - public TitleBarButton(RectangleList unchecked, RectangleList checked) { - super(); - uncheckedRects = unchecked; - checkedRects = checked; - initialize(); - } - - public boolean getState() { - return state; - } - - public void setState(boolean newState) { - state = newState; - hilite = false; - } - - private void initialize() { - setRequestFocusEnabled(true); - setFocusTraversable(true); - - if (uncheckedImage != null) { - org.eclipse.swt.graphics.Rectangle r = uncheckedImage.getBounds(); - setBounds(new Rectangle(0, 0, r.width, r.height)); - prefSize = new Dimension(r.width, r.height); - } else { - setForegroundColor(ColorConstants.black); - setBackgroundColor(ColorConstants.white); - calculatePreferredSize(); - setBounds(new Rectangle(0, 0, prefSize.width, prefSize.height)); - } - setCursor(Cursors.ARROW); - setBorder(null); - setFont(JFaceResources.getFontRegistry().get( - JFaceResources.DEFAULT_FONT)); - - addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent event) { - setState(!state); - } - }); - this.addMouseMotionListener(new MouseMotionListener() { - - public void mouseDragged(MouseEvent me) { - // TODO Auto-generated method stub - - } - - public void mouseEntered(MouseEvent me) { - hilite = true; - repaint(); - } - - public void mouseExited(MouseEvent me) { - hilite = false; - repaint(); - } - - public void mouseHover(MouseEvent me) { - // TODO Auto-generated method stub - - } - - public void mouseMoved(MouseEvent me) { - // TODO Auto-generated method stub - - } - }); - } - - public Dimension calculatePreferredSize() { - if (prefSize == null) { - Rectangle rect = new Rectangle(0, 0, 0, 0); - if (uncheckedRects != null) { - Iterator iter = uncheckedRects.getRectangles().iterator(); - while (iter.hasNext()) { - /*Point p =*/ getLocation(); - Rectangle r = ((Rectangle) iter.next()).getCopy(); - rect = rect.getUnion(r); - } - } - if (checkedRects != null) { - Iterator iter = checkedRects.getRectangles().iterator(); - while (iter.hasNext()) { - /*Point p =*/ getLocation(); - Rectangle r = ((Rectangle) iter.next()).getCopy(); - rect = rect.getUnion(r); - } - } - prefSize = rect.getSize(); - if (prefSize.width > prefSize.height) - prefSize.height = prefSize.width; - else if (prefSize.height > prefSize.width) - prefSize.width = prefSize.height; - prefSize.width += 4; - prefSize.height += 4; - } - return prefSize; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.IFigure#paint(org.eclipse.draw2d.Graphics) - */ - public void paint(Graphics graphics) { - if (!isVisible()) - return; - if (uncheckedImage != null) { - if (hilite) { - if (state == false) - graphics.drawImage(uncheckedHiliteImage, getLocation()); - else - graphics.drawImage(checkedHiliteImage, getLocation()); - } else { - if (state == false) - graphics.drawImage(uncheckedImage, getLocation()); - else - graphics.drawImage(checkedImage, getLocation()); - } - } else { - Iterator iter = null; - if (state == false) - iter = uncheckedRects.getRectangles().iterator(); - else - iter = checkedRects.getRectangles().iterator(); - while (iter.hasNext()) { - Point p = getLocation(); - Rectangle r = ((Rectangle) iter.next()).getCopy(); - r = r.translate(p.x, p.y); - graphics.setForegroundColor(getForegroundColor()); - if (hilite) - graphics.setBackgroundColor(ColorConstants.lightBlue); - else - graphics.setBackgroundColor(ColorConstants.white); - graphics.fillRectangle(r); - graphics.drawRectangle(r); - } - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/WindowFigure.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/WindowFigure.java deleted file mode 100644 index 57e606252..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/WindowFigure.java +++ /dev/null @@ -1,570 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.preference; - -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.draw2d.AncestorListener; -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.ConnectionLayer; -import org.eclipse.draw2d.FreeformFigure; -import org.eclipse.draw2d.FreeformLayer; -import org.eclipse.draw2d.FreeformLayeredPane; -import org.eclipse.draw2d.FreeformLayout; -import org.eclipse.draw2d.FreeformListener; -import org.eclipse.draw2d.FreeformViewport; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Layer; -import org.eclipse.draw2d.LayeredPane; -import org.eclipse.draw2d.ScalableFreeformLayeredPane; -import org.eclipse.draw2d.ScrollPane; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Insets; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.LayerConstants; -import org.eclipse.gef.editparts.GridLayer; -import org.eclipse.gef.editparts.GuideLayer; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; - -public class WindowFigure extends ScrollPane implements IContainerFigure, - LayerConstants, FreeformFigure { - private TabbedWindowBorder windowBorder; - - private TabbedTitleBarBorder titleBarBorder; - - private FreeformViewport myViewport; - - // private FreeformLayeredPane layeredPane; - - private ScalableFreeformLayeredPane scaledLayers; - - private LayeredPane innerLayers; - - private LayeredPane printableLayers; - - private FreeformLayer primaryLayer; - - public static Font defaultFont = JFaceResources.getFontRegistry().get( - JFaceResources.DEFAULT_FONT); - - public static Color defaultForegroundColor = ColorConstants.black; - - public static Color defaultBackgroundColor = ColorConstants.white; - - public static Color defaultGridColor = ColorConstants.lightGray; - - public static Dimension defaultGridSpacing = null; - - public static boolean defaultGridEnabled = false; - - // Line Routing is not used within the WindowFigure class; it just serves as - // a storage - // location for communicating between the GEMPreferences and EditParts that - // actually - // create the line routers. - public static int LINE_ROUTING_MANUAL = 0; - - public static int LINE_ROUTING_MANHATTAN = 1; - - public static int defaultLineRoutingStyle = LINE_ROUTING_MANUAL; - - private class MyGridLayer extends GridLayer { - public Point getOrigin() { - return origin.getCopy(); - } - } - - private class MyFeedbackLayer extends FreeformLayer { - MyFeedbackLayer() { - setEnabled(false); - } - } - - public WindowFigure() { - super(); - - windowBorder = new TabbedWindowBorder(this); - titleBarBorder = (TabbedTitleBarBorder) windowBorder.getInnerBorder(); - setBorder(windowBorder); - setFont(defaultFont); - setForegroundColor(defaultForegroundColor); - setBackgroundColor(defaultBackgroundColor); - - innerLayers = new FreeformLayeredPane(); - createLayers(innerLayers); - - myViewport = new FreeformViewport(); - myViewport.setContents(innerLayers); - - setViewport(myViewport); - - // CR389495: Working with nested complex activities causes in the BP - // editor causes lockup - // not related to this CR but discovered while working on it: - // make sure we observe grid visibility from preferences - getGridLayer().setVisible(defaultGridEnabled); - getGridLayer().setSpacing(defaultGridSpacing); - getGridLayer().setForegroundColor(defaultGridColor); - - setText("Window"); - - addTabbedWindowListener(new WindowFigureListener() { - public void tabChanged(int oldIndex, int newIndex) { - internalSetCurrentTab(newIndex); - validate(); - } - }); - addAncestorListener(new AncestorListener() { - - public void ancestorAdded(IFigure ancestor) { - setVisible(true); - } - - public void ancestorMoved(IFigure ancestor) { - // validateComposite(); - } - - public void ancestorRemoved(IFigure ancestor) { - // TODO: fix this - shouldn't be throwing an exception - try { - setVisible(false); - } catch (Exception e) { - EditorPlugin.getDefault().getLog().log( - new Status(IStatus.ERROR, EditorPlugin.getPluginId(), 0, "Error setting visible", e)); - } - } - }); - } - - // ////////////////////////////////////////////////////////////////////////// - // Layer management - // ////////////////////////////////////////////////////////////////////////// - - protected void createLayers(LayeredPane layeredPane) { - layeredPane.add(getScaledLayers(), SCALABLE_LAYERS); - layeredPane.add(new FreeformLayer(), HANDLE_LAYER); - // CR377650: Horizontal scrolling needs to be improved - // moved the feedback layer into printable layers so it shows up in - // content outline - // layeredPane.add(new MyFeedbackLayer(), FEEDBACK_LAYER); - layeredPane.add(new GuideLayer(), GUIDE_LAYER); - } - - protected ScalableFreeformLayeredPane createScaledLayers() { - ScalableFreeformLayeredPane layers = new ScalableFreeformLayeredPane(); - layers.add(createGridLayer(), GRID_LAYER); - layers.add(getPrintableLayers(), PRINTABLE_LAYERS); - // CR389070: Figures are abbreviating rule figures names and making them - // unreadable - // not needed (?) - // layers.add(new MyFeedbackLayer(), SCALED_FEEDBACK_LAYER); - return layers; - } - - protected LayeredPane getScaledLayers() { - if (scaledLayers == null) - scaledLayers = createScaledLayers(); - return scaledLayers; - } - - protected LayeredPane createPrintableLayers() { - FreeformLayeredPane layeredPane = new FreeformLayeredPane(); - - PrintedPageLayer pageTileLayer = new PrintedPageLayer(this); - // TODO: get the printer page size from printer preferences - // and set into the PageTileLayer. - pageTileLayer.setPageSize(new Dimension(0, 0)); - layeredPane.add(pageTileLayer, PrintedPageLayer.PRINTED_PAGE_LAYER, -1); - - // CR400208: Lines bleed from the bp canvas through the Fault handler - // window - // changed z-order of connection layer so that it is below figures - layeredPane.add(new ConnectionLayer(), CONNECTION_LAYER, -1); - primaryLayer = new FreeformLayer(); - layeredPane.add(primaryLayer, PRIMARY_LAYER, -1); - primaryLayer.setLayoutManager(new FreeformLayout()); - - // CR377650: Horizontal scrolling needs to be improved - // let's put the feedback layer in with the printable layers so - // we can see the feedback figures in the content outline viewer - layeredPane.add(new MyFeedbackLayer(), FEEDBACK_LAYER); - return layeredPane; - } - - protected LayeredPane getPrintableLayers() { - if (printableLayers == null) - printableLayers = createPrintableLayers(); - return printableLayers; - } - - protected GridLayer createGridLayer() { - return new MyGridLayer(); - } - - public GridLayer getGridLayer() { - return (GridLayer) getLayer(GRID_LAYER); - } - - public Layer getLayer(Object key) { - // ScalableFreeformRootEditPart: - Layer layer = null; - if (scaledLayers != null) - layer = scaledLayers.getLayer(key); - if (layer != null) - return layer; - // FreeformGraphicalRootEditPart: - if (innerLayers == null) - return null; - layer = innerLayers.getLayer(key); - if (layer != null) - return layer; - if (printableLayers == null) - return null; - return printableLayers.getLayer(key); - } - - // ////////////////////////////////////////////////////////////////////////// - // Properties - // ////////////////////////////////////////////////////////////////////////// - - public Point getScrollPosition() { - int x = getHorizontalScrollBar().getRangeModel().getValue(); - int y = getVerticalScrollBar().getRangeModel().getValue(); - return new Point(x, y); - } - - public TabbedTitleBarBorder getTabbedTitleBarBorder() { - return titleBarBorder; - } - - public TabbedWindowBorder getTabbedWindowBorder() { - return windowBorder; - } - - public void addTabbedWindowListener(WindowFigureListener listener) { - titleBarBorder.addTabbedWindowListener(listener); - } - - public void removeTabbedWindowListener(WindowFigureListener listener) { - titleBarBorder.removeTabbedWindowListener(listener); - } - - public Dimension getMinimumSize(int wHint, int hHint) { - Dimension d = titleBarBorder.getMinimumSize(wHint, hHint); - d.expand(getInsets().getWidth(), getInsets().getHeight()); - return d; - } - - public int addTab(String s) { - return titleBarBorder.addTab(s); - } - - public void removeTab(int index) { - titleBarBorder.removeTab(index); - internalSetCurrentTab(titleBarBorder.getCurrentTab()); - } - - private void internalSetCurrentTab(int index) { - // Object contents = titleBarBorder.getContents(index); - // if (contents instanceof IFigure) - // setContents((IFigure) contents); - } - - public void setCurrentTab(int index) { - internalSetCurrentTab(index); - titleBarBorder.setCurrentTab(index); - } - - public int getCurrentTab() { - return titleBarBorder.getCurrentTab(); - } - - public void setContents(IFigure figure) { - titleBarBorder.setContents(0, figure); - super.setContents(figure); - } - - public void setContents(int index, Object contents) { - if (contents instanceof IFigure) - setContents((IFigure) contents); - titleBarBorder.setContents(index, contents); - } - - public Object getContents(int index) { - return titleBarBorder.getContents(index); - } - - public void setVisible(boolean flag) { - super.setVisible(flag); - windowBorder.setVisible(flag); - // hide/show the window contents if it's a SWT composite - Object contents = getContents(); - if (contents instanceof Composite) - ((Composite) contents).setVisible(flag); - } - - public void setHighlight(boolean flag) { - windowBorder.setHighlight(flag); - } - - public void setFont(Font f) { - titleBarBorder.setFont(f); - } - - public void setForegroundColor(Color c) { - titleBarBorder.setTextColor(c); - } - - public void setLineRoutingStyle(int style) { - defaultLineRoutingStyle = style; - revalidate(); - } - - public int getLineRoutingStyle() { - return defaultLineRoutingStyle; - } - - public Dimension getPreferredSize(int wHint, int hHint) { - if (prefSize == null) { - IFigure parent = getParent(); - prefSize = parent.getSize(); - this.getLayoutManager().invalidate(); - Dimension m = super.getPreferredSize(wHint, hHint); - if (getParent() instanceof CompoundNodeFigure) { - if (((CompoundNodeFigure) parent).getState() == CompoundNodeFigure.RESTORED) { - Insets in = ((CompoundNodeFigure) getParent()) - .getAnchorInsets(); - prefSize.width -= in.getWidth(); - prefSize.height -= in.getHeight(); - } - } else { - if (m.width > prefSize.width) - prefSize.width = m.width; - if (m.height > prefSize.height) - prefSize.height = m.height; - } - } - return prefSize; - } - - protected boolean isValidationRoot() { - return true; - } - - // private void validateComposite() { - // Object contents = getContents(); - // // System.out.println("validate: "+titleBarBorder.getLabel(0)+" - // // "+contents); - // if (contents instanceof Composite) { - // if (getParent() == null) { - // System.err.println("TabbedWindowFigure.validate() - ERROR"); - // return; - // } - // Rectangle r = getBounds().getCopy(); - // r.crop(getInsets()); - // Dimension ps = getParent().getParent().getPreferredSize(); - // Rectangle pr = getParent().getParent().getBounds(); - // titleBarBorder.invalidate(); - // titleBarBorder.getInsets(this); - // Insets in = getParent().getParent().getInsets(); - // Composite comp = (Composite) getContents(); - // comp.setBounds(pr.x + r.x + in.left, pr.y + r.y, r.width, r.height); - // comp.moveAbove(null); - // } - // } - - public void invalidate() { - prefSize = null; - super.invalidate(); - } - - // ////////////////////////////////////////////////////////////////////// - // IBaseFigure methods - // ////////////////////////////////////////////////////////////////////// - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#setText(String - * text) - */ - public void setText(String name) { - titleBarBorder.setLabel(name); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.basic.ITabbedWindow#setName(int, - * java.lang.String) - */ - public void setText(int index, String name) { - titleBarBorder.setLabel(index, name); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#getText() - */ - public String getText() { - if (titleBarBorder == null) - return "??"; - return titleBarBorder.getLabel(); - } - - /* - * CR374981: Long activity labels do not get wrapped or truncated This - * method was added to the IBaseFigure interface to support direct edit of - * figure labels on the canvas. - */ - public Rectangle getTextBounds() { - Rectangle r = getClientArea().getCopy(); - r.height = titleBarBorder.getTextExtents(this).height; - r.x += getInsets().left; - r.y -= getInsets().top; - return r; - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#getIcon() - */ - public Image getIcon() { - return null; - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#setIcon(org.eclipse.swt.graphics.Image) - */ - public void setIcon(Image image) { - // do nothing - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#setToolTipText(java.lang.String) - */ - public void setToolTipText(String text) { - // do nothing - } - - public String getToolTipText() { - return null; - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#addDecorator(com.sybase.stf.gem.diagram.editor.figures.BaseFigureDecorator) - */ - public void addDecorator(BaseFigureDecorator decorator) { - // do nothing - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#removeDecorator() - */ - public void removeDecorator() { - // do nothing - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#removeDecorator(int) - */ - public void removeDecorator(int position) { - // do nothing - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.gem.diagram.editor.figures.IBaseFigure#getDecorators() - */ - public List getDecorators() { - return null; - } - - // ////////////////////////////////////////////////////////////////////// - // FreeformFigure methods - // ////////////////////////////////////////////////////////////////////// - - private WindowFreeformHelper helper = new WindowFreeformHelper(this); - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.FreeformFigure#addFreeformListener(org.eclipse.draw2d.FreeformListener) - */ - public void addFreeformListener(FreeformListener listener) { - addListener(FreeformListener.class, listener); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.FreeformFigure#fireExtentChanged() - */ - public void fireExtentChanged() { - Iterator iter = getListeners(FreeformListener.class); - while (iter.hasNext()) - ((FreeformListener) iter.next()).notifyFreeformExtentChanged(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.FreeformFigure#getFreeformExtent() - */ - public Rectangle getFreeformExtent() { - Rectangle r = helper.getFreeformExtent(); - r.x = 0; - r.y = 0; - return r; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.FreeformFigure#removeFreeformListener(org.eclipse.draw2d.FreeformListener) - */ - public void removeFreeformListener(FreeformListener listener) { - removeListener(FreeformListener.class, listener); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.draw2d.FreeformFigure#setFreeformBounds(org.eclipse.draw2d.geometry.Rectangle) - */ - public void setFreeformBounds(Rectangle bounds) { - helper.setFreeformBounds(bounds); - } -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/WindowFigureListener.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/WindowFigureListener.java deleted file mode 100644 index 0a6d4b12d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/WindowFigureListener.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.preference; - -/** - * @author Bob Brodt - * - * Defines an interface for notifying listeners of page switches on a tabbed - * window figure. - */ -public interface WindowFigureListener { - void tabChanged(int oldIndex, int newIndex); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/WindowFreeformHelper.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/WindowFreeformHelper.java deleted file mode 100644 index 834d51658..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/preference/WindowFreeformHelper.java +++ /dev/null @@ -1,124 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.preference; - -import java.util.List; - -import org.eclipse.draw2d.FigureListener; -import org.eclipse.draw2d.FreeformFigure; -import org.eclipse.draw2d.FreeformLayeredPane; -import org.eclipse.draw2d.FreeformListener; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.geometry.Insets; -import org.eclipse.draw2d.geometry.Rectangle; - -/** - * Stolen from org.eclipse.draw2d.FreeformHelper. See also FreeformLayeredPane. - * - * @author bbrodt - */ -public class WindowFreeformHelper implements FreeformListener { - FreeformLayeredPane x; - - class ChildTracker implements FigureListener { - public void figureMoved(IFigure source) { - invalidate(); - } - } - - private FreeformFigure host; - - private Rectangle freeformExtent; - - private FigureListener figureListener = new ChildTracker(); - - public WindowFreeformHelper(FreeformFigure host) { - this.host = host; - } - - public Rectangle getFreeformExtent() { - if (freeformExtent != null) - return freeformExtent; - Rectangle r; - List children = host.getChildren(); - for (int i = 0; i < children.size(); i++) { - IFigure child = (IFigure) children.get(i); - if (child instanceof FreeformFigure) - r = ((FreeformFigure) child).getFreeformExtent(); - else - r = child.getBounds(); - if (freeformExtent == null) - freeformExtent = r.getCopy(); - else - freeformExtent.union(r); - } - Insets insets = host.getInsets(); - if (freeformExtent == null) - freeformExtent = new Rectangle(0, 0, insets.getWidth(), insets - .getHeight()); - else { - host.translateToParent(freeformExtent); - freeformExtent.expand(insets); - } - // System.out.println("New extent calculated for " + host + " = " + - // freeformExtent); - return freeformExtent; - } - - public void hookChild(IFigure child) { - invalidate(); - if (child instanceof FreeformFigure) - ((FreeformFigure) child).addFreeformListener(this); - else - child.addFigureListener(figureListener); - } - - void invalidate() { - freeformExtent = null; - host.fireExtentChanged(); - if (host.getParent() != null) - host.getParent().revalidate(); - else - host.revalidate(); - } - - public void notifyFreeformExtentChanged() { - // A childs freeform extent has changed, therefore this extent must be - // recalculated - invalidate(); - } - - public void setFreeformBounds(Rectangle bounds) { - host.setBounds(bounds); - bounds = bounds.getCopy(); - host.translateFromParent(bounds); - List children = host.getChildren(); - for (int i = 0; i < children.size(); i++) { - IFigure child = (IFigure) children.get(i); - if (child instanceof FreeformFigure) - ((FreeformFigure) child).setFreeformBounds(bounds); - } - // CR420954: Compensation Handler canvas goes blank after Variables - // Sections is expanded - host.getLayoutManager().layout(host); - } - - public void unhookChild(IFigure child) { - invalidate(); - if (child instanceof FreeformFigure) - ((FreeformFigure) child).removeFreeformListener(this); - else - child.removeFigureListener(figureListener); - } - -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/provider/ManagedBeanContentProvider.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/provider/ManagedBeanContentProvider.java deleted file mode 100644 index 45d15b4c3..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/provider/ManagedBeanContentProvider.java +++ /dev/null @@ -1,138 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.provider; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigType; -import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanType; -import org.eclipse.jst.jsf.facesconfig.ui.section.ManagedBeanScopeTreeItem; - -/** - * Managed bean Content Provider. - * <p> - * <b>Provides grouping by Scope.</b> - * </p> - * - * @author Xiao-guang Zhang, sfshi - * @version 1.5 - */ -public class ManagedBeanContentProvider implements ITreeContentProvider { - - private List scopeItemList = null; - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(Object - * parent) - */ - public Object[] getChildren(Object parent) { - - if (parent instanceof FacesConfigType) { - if (scopeItemList == null) { - scopeItemList = new ArrayList(); - for (int i = 0; i < ManagedBeanScopeTreeItem.scopeItems.length; i++) { - ManagedBeanScopeTreeItem scopeTreeItem = new ManagedBeanScopeTreeItem( - ManagedBeanScopeTreeItem.scopeItems[i], - (FacesConfigType) parent); - scopeItemList.add(scopeTreeItem); - } - } - return scopeItemList.toArray(); - } else if (parent instanceof ManagedBeanScopeTreeItem) { - return ((ManagedBeanScopeTreeItem) parent).getChildren().toArray(); - } - - return new Object[0]; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ITreeContentProvider#getElements(Object - * parent) - */ - public Object[] getElements(Object inputElement) { - return getChildren(inputElement); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object) - */ - public Object getParent(Object element) { - if (element instanceof ManagedBeanScopeTreeItem) { - return ((ManagedBeanScopeTreeItem) element).getParent(); - } else if (element instanceof ManagedBeanType) { - String scope = null; - if (((ManagedBeanType) element).getManagedBeanScope() != null) { - scope = ((ManagedBeanType) element).getManagedBeanScope() - .getTextContent(); - } - - if (scope != null) { - for (int i = 0; i < scopeItemList.size(); i++) { - if (((ManagedBeanScopeTreeItem) scopeItemList.get(i)) - .getScope().equals(scope)) { - return scopeItemList.get(i); - } - - } - } - } - - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object) - */ - public boolean hasChildren(Object element) { - if (element instanceof FacesConfigType) { - return true; - } else if (element instanceof ManagedBeanScopeTreeItem) { - return ((ManagedBeanScopeTreeItem) element).hasChildren(); - } - return false; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IContentProvider#dispose() - */ - public void dispose() { - // TODO Auto-generated method stub - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, - * java.lang.Object, java.lang.Object) - */ - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - if (newInput != null) { -// initialize(newInput); - } - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/provider/ManagedBeanLabelProvider.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/provider/ManagedBeanLabelProvider.java deleted file mode 100644 index 3a729c8e0..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/provider/ManagedBeanLabelProvider.java +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.provider; - -import java.util.Hashtable; -import java.util.Map; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanType; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.IFacesConfigConstants; -import org.eclipse.jst.jsf.facesconfig.ui.section.ManagedBeanScopeTreeItem; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; - -/** - * The Managed Bean Page's TreeViewer Label Provider - * - * @author Xiao-guang Zhang, sfshi - * @version 1.5 - */ -public class ManagedBeanLabelProvider extends LabelProvider { - /** Cache of images that have been dispensed by this provider */ - private Map imageTable; - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.LabelProvider#getText(Object obj) - */ - public String getText(Object obj) { - String text = ""; - - if (obj instanceof ManagedBeanType) { - ManagedBeanType bean = (ManagedBeanType) obj; - if (bean.getManagedBeanName() != null) { - text = bean.getManagedBeanName().getTextContent(); - - } - if (text == null || text.length() < 1) { - if (bean.getManagedBeanClass() != null) - text = bean.getManagedBeanClass().getTextContent(); - } - } else if (obj instanceof ManagedBeanScopeTreeItem) { - text = ((ManagedBeanScopeTreeItem) obj).getScope(); - } - - return text; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.LabelProvider#getImage(Object obj) - */ - public Image getImage(Object obj) { - ImageDescriptor imageDesc = null; - if (obj instanceof ManagedBeanType) { - - imageDesc = EditorPlugin.getDefault().getImageDescriptor( - "facesconfig/FacesConfig_ManagedBean.gif"); //$NON-NLS-1$ - - } else if (obj instanceof ManagedBeanScopeTreeItem) { - ManagedBeanScopeTreeItem scopeTreeItem = (ManagedBeanScopeTreeItem) obj; - if (IFacesConfigConstants.MANAGED_BEAN_SCOPE_SESSION - .equals(scopeTreeItem.getScope())) { - imageDesc = EditorPlugin.getDefault().getImageDescriptor( - "Scope_Session.gif"); - } else if (IFacesConfigConstants.MANAGED_BEAN_SCOPE_REQUEST - .equals(scopeTreeItem.getScope())) { - imageDesc = EditorPlugin.getDefault().getImageDescriptor( - "Scope_Request.gif"); - } else if (IFacesConfigConstants.MANAGED_BEAN_SCOPE_APPLICATION - .equals(scopeTreeItem.getScope())) { - imageDesc = EditorPlugin.getDefault().getImageDescriptor( - "Scope_Application.gif"); - } else if (IFacesConfigConstants.MANAGED_BEAN_SCOPE_NONE - .equals(scopeTreeItem.getScope())) { - imageDesc = EditorPlugin.getDefault().getImageDescriptor( - "Scope_None.gif"); - } else { - imageDesc = EditorPlugin.getDefault().getImageDescriptor( - "Scope.gif"); - } - } - - if (imageDesc != null) { - // Obtain the cached image corresponding to the descriptor - if (imageTable == null) { - imageTable = new Hashtable(40); - } - Image image = (Image) imageTable.get(imageDesc); - if (image == null) { - image = imageDesc.createImage(); - imageTable.put(imageDesc, image); - } - return image; - } - return PlatformUI.getWorkbench().getSharedImages().getImage( - ISharedImages.IMG_OBJ_ELEMENT); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/AbstractFacesConfigSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/AbstractFacesConfigSection.java deleted file mode 100644 index 8d4748938..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/AbstractFacesConfigSection.java +++ /dev/null @@ -1,288 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.section; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.emf.common.notify.AdapterFactory; -import org.eclipse.emf.edit.domain.EditingDomain; -import org.eclipse.help.HelpSystem; -import org.eclipse.help.IContext; -import org.eclipse.help.IHelpResource; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.page.IFacesConfigPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.SectionPart; -import org.eclipse.ui.forms.events.HyperlinkAdapter; -import org.eclipse.ui.forms.events.HyperlinkEvent; -import org.eclipse.ui.forms.widgets.ExpandableComposite; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.forms.widgets.ImageHyperlink; -import org.eclipse.ui.forms.widgets.Section; - -/** - * The abstract implementation of IFacesConfigSection. - * - * - * @author jchoi, xgzhang, sfshi - * - * @version 1.0 - */ -public abstract class AbstractFacesConfigSection extends SectionPart implements - IFacesConfigSection, ISelectionProvider, ISelectionChangedListener { - /** tool kit */ - private FormToolkit toolkit; - - /** help context id */ - private String helpContextId = null; - - /** help tool tip string */ - private String helpTooltip = null; - - /** model object */ - private Object input = null; - - private IFacesConfigPage page; - - private List selectionChangedListeners = new ArrayList(); - - /** help image */ - private final static Image HELP_IMAGE = EditorPlugin.getDefault().getImage( - "help.gif"); //$NON-NLS-1$ - - /** - * Constructor with help option. - - * @param parent - * @param managedForm - * @param page - * @param toolkit - * @param helpContextId - * @param helpTooltip - */ - public AbstractFacesConfigSection(Composite parent, - IManagedForm managedForm, IFacesConfigPage page, - FormToolkit toolkit, String helpContextId, String helpTooltip) { - super(parent, toolkit, ExpandableComposite.TITLE_BAR - | ExpandableComposite.TWISTIE | Section.DESCRIPTION - | ExpandableComposite.EXPANDED); - super.initialize(managedForm); - this.page = page; - this.toolkit = toolkit; - this.helpContextId = helpContextId; - this.helpTooltip = helpTooltip; - } - - /** - * - */ - public void initialize() { - if (helpContextId != null) { - createTextClientWithHelp(); - } - - getSection().setLayout(new GridLayout()); - - Composite clientContainer = toolkit.createComposite(getSection()); - GridData gd = new GridData(GridData.FILL_BOTH); - clientContainer.setLayoutData(gd); - - createContents(clientContainer, toolkit); - getSection().setClient(clientContainer); - - } - - /** - * - * - */ - private void createTextClientWithHelp() { - ImageHyperlink helpImage = new ImageHyperlink(getSection(), SWT.NULL); - - toolkit.adapt(helpImage, true, true); - - helpImage.setImage(HELP_IMAGE); //$NON-NLS-1$ - - helpImage.setBackground(getSection().getTitleBarGradientBackground()); - if (helpTooltip != null) { - helpImage.setToolTipText(helpTooltip); - } - - helpImage.addHyperlinkListener(new HyperlinkAdapter() { - public void linkActivated(HyperlinkEvent e) { - IContext context = HelpSystem.getContext(helpContextId); - if (context != null) { - IHelpResource[] topics = context.getRelatedTopics(); - if (topics != null && topics.length == 1) { - EditorPlugin.getDefault().getWorkbench() - .getHelpSystem().displayHelpResource( - topics[0].getHref()); - } else { - EditorPlugin.getDefault().getWorkbench() - .getHelpSystem().displayHelp(helpContextId); - } - } - } - }); - - getSection().setTextClient(helpImage); - } - - /** - * The sub calss should implement this method to create and fill the - * contents in the section - * - * @param container - * @param toolkit_ - */ - protected abstract void createContents(Composite container, - FormToolkit toolkit_); - - /** - * get the input object of this section. - */ - public Object getInput() { - return input; - } - - /** - * set input object for this section. - */ - public void setInput(Object newInput) { - if (input != null) - removeAdaptersFromInput(input); - - input = newInput; - - if (newInput != null) - addAdaptersOntoInput(newInput); - // if (this.getSection().isExpanded()) - refreshAll(); - } - - /** - * Remove adapters from the input object when the section changes it's - * input. Sub classes should overwrite this method to remove the adapters - * that they added on. - * - * @param oldInput - */ - protected void removeAdaptersFromInput(Object oldInput) { - // do nothing; subs should override - } - - /** - * Add adapters onto the input object when the section has new input. Sub - * classes should their own adapters. - * - * @param newInput - */ - protected void addAdaptersOntoInput(Object newInput) { - // do nothing; subs should override - } - - /** - * @return the page that this section lies in. - */ - public IFacesConfigPage getPage() { - return page; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection() - */ - public ISelection getSelection() { - return StructuredSelection.EMPTY; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection) - */ - public void setSelection(ISelection selection) { - // do nothing: no selection change - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ISelectionProvider#addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) - */ - public void addSelectionChangedListener(ISelectionChangedListener listener) { - selectionChangedListeners.add(listener); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ISelectionProvider#removeSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) - */ - public void removeSelectionChangedListener( - ISelectionChangedListener listener) { - selectionChangedListeners.remove(listener); - } - - /** - * transfer the selection changed event to detail part. - */ - public void selectionChanged(SelectionChangedEvent event) { - - for (Iterator listeners = selectionChangedListeners.iterator(); listeners - .hasNext();) { - ISelectionChangedListener listener = (ISelectionChangedListener) listeners - .next(); - listener.selectionChanged(new SelectionChangedEvent(this, - event != null ? event.getSelection() - : StructuredSelection.EMPTY)); - } - } - - /** - * the convenient method to get the AdapterFactory instance of the editor; - * - * @return the AdapterFactory instance. - */ - public AdapterFactory getAdapterFactory() { - return (AdapterFactory) getPage().getEditor().getAdapter( - AdapterFactory.class); - } - - /** - * the convenient method to get the EditingDomain instance of the editor; - * - * @return the EditingDomain instance. - */ - public EditingDomain getEditingDomain() { - return (EditingDomain) getPage().getEditor().getAdapter( - EditingDomain.class); - } - - public void clearAll() - { - // do nothing, sub-classes may choose to override to clear their contents - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/AbstractOverviewSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/AbstractOverviewSection.java deleted file mode 100644 index 34b51e9f0..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/AbstractOverviewSection.java +++ /dev/null @@ -1,136 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.section; - -import org.eclipse.emf.edit.provider.ComposedAdapterFactory; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jst.jsf.common.ui.internal.actions.OpenPageAction; -import org.eclipse.jst.jsf.facesconfig.ui.page.IFacesConfigPage; -import org.eclipse.swt.events.MouseAdapter; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Table; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * @author sfshi - * - */ -public abstract class AbstractOverviewSection extends - AbstractFacesConfigSection { - - /** - * the common table viewer used for the contents - */ - protected TableViewer tableViewer; - - private String targetPageID; - - /** - * - * @param parent - * @param managedForm - * @param page - * @param toolkit - * @param targetPageID - * @param title - * @param description - * @param helpContextId - * @param helpTooltip - */ - public AbstractOverviewSection(Composite parent, IManagedForm managedForm, - IFacesConfigPage page, FormToolkit toolkit, String targetPageID, - String title, String description, String helpContextId, - String helpTooltip) { - super(parent, managedForm, page, toolkit, helpContextId, helpTooltip); - this.targetPageID = targetPageID; - getSection().setText(title); //$NON-NLS-1$ - getSection().setDescription(description); //$NON-NLS-1$ - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.section.AbstractFacesConfigSection#createContents(org.eclipse.swt.widgets.Composite, - * org.eclipse.ui.forms.widgets.FormToolkit) - */ - protected void createContents(Composite container, FormToolkit toolkit) { - - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - layout.marginHeight = 2; - layout.marginWidth = 2; - layout.verticalSpacing = 5; - layout.horizontalSpacing = 6; - container.setLayout(layout); - toolkit.paintBordersFor(container); - Table table = createTable(container); - if (targetPageID != null) { - table.addMouseListener(new MouseAdapter() { - public void mouseDoubleClick(MouseEvent e) { - if (((IStructuredSelection) tableViewer.getSelection()) - .size() == 1) { - OpenPageAction action = new OpenPageAction(); - action.setPageName(targetPageID); - action.setSelection(tableViewer.getSelection()); - action.run(); - } - } - }); - } - tableViewer = new TableViewer(table); - tableViewer.setContentProvider(new AdapterFactoryContentProvider( - getAdapterFactory())); - ComposedAdapterFactory factory = (ComposedAdapterFactory)getAdapterFactory(); - tableViewer.setLabelProvider(new AdapterFactoryLabelProvider(factory)); - configTableViewer(tableViewer); - } - - /** - * - * @param container - * @return the table - */ - abstract protected Table createTable(Composite container); - - /** - * - * @param tableViewer1 - */ - abstract protected void configTableViewer(TableViewer tableViewer1); - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.section.IFacesConfigSection#clearAll() - */ - public void clearAll() { - tableViewer.setInput(null); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.section.IFacesConfigSection#refreshAll() - */ - public void refreshAll() { - tableViewer.setInput(getInput()); - - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ApplicationSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ApplicationSection.java deleted file mode 100644 index b121d0ec8..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ApplicationSection.java +++ /dev/null @@ -1,216 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.section; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.common.command.CompoundCommand; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.edit.command.AddCommand; -import org.eclipse.jdt.ui.IJavaElementSearchConstants; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jst.jsf.facesconfig.emf.ApplicationType; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigType; -import org.eclipse.jst.jsf.facesconfig.ui.dialog.DialogUtil; -import org.eclipse.jst.jsf.facesconfig.ui.page.IFacesConfigPage; -import org.eclipse.jst.jsf.facesconfig.ui.page.OthersPage; -import org.eclipse.jst.jsf.facesconfig.ui.util.ModelUtil; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * A common <code>IFacesConfigSection</code> implementation for the sections that editing - * the child elements of <application>, including: <action-listener>, - * <default-render-kit-id>, <message-bundle>, <navigation-handler>, - * <view-handler>,<state-manager>, <property-resolver>, <variable-resolver> and - * <locale-config>. This sections will use the EClass object of these elements - * as the key. - * - * @author Zhi-peng Zhang, sfshi - * @version - */ -public class ApplicationSection extends OthersPageBaseSection { - - /** The Eclass object this Section operated */ - private EClass applicationChildClass; - - /** - * - * @param applicationChildClass - * @param parent - * @param managedForm - * @param page - * @param toolkit - * @param helpContextId - * @param helpTooltip - */ - public ApplicationSection(EClass applicationChildClass, Composite parent, - IManagedForm managedForm, IFacesConfigPage page, - FormToolkit toolkit, String helpContextId, String helpTooltip) { - super(parent, managedForm, page, toolkit, helpContextId, helpTooltip); - this.applicationChildClass = applicationChildClass; - } - - /** - * - * @param componentClass - * @param parent - * @param managedForm - * @param page - * @param toolkit - */ - public ApplicationSection(EClass componentClass, Composite parent, - IManagedForm managedForm, IFacesConfigPage page, FormToolkit toolkit) { - this(componentClass, parent, managedForm, page, toolkit, null, null); - } - - /** - * Create an object which is instance of <code>applicationChildClass</code>. - * - * @return the child class object - */ - public EObject createApplicationChildObject() { - String textValue = null; - IProject project = (IProject) this.getPage().getEditor().getAdapter( - IProject.class); - FacesConfigType facesConfig = (FacesConfigType) this.getPage() - .getInput(); - if (applicationChildClass == FacesConfigPackage.eINSTANCE - .getDefaultRenderKitIdType()) { - - /** Open a dialog to select a render-kit of this faces config. */ - textValue = DialogUtil.openRenderKitDialog(getSection().getShell(), - facesConfig); - } else if (applicationChildClass == FacesConfigPackage.eINSTANCE - .getMessageBundleType()) { - /** - * Open a dialog the select the message bundles that in current - * project. If user select a bundle that already declared in this - * faces config, then shows a warning message. - */ - List bundles = new ArrayList(); - if (facesConfig.getApplication().size() > 0) { - ApplicationType applicationType = (ApplicationType) facesConfig - .getApplication().get(0); - bundles = applicationType.getMessageBundle(); - } - - textValue = DialogUtil.openMessageBundleDialog(getSection() - .getShell(), project, bundles); - - } else { - /** - * For other types children, open a ClassDialog to select a class in - * current project. - */ - String superType = ModelUtil.getSuperType(applicationChildClass); - textValue = DialogUtil.openClassDialog(getSection().getShell(), - project, superType, - IJavaElementSearchConstants.CONSIDER_ALL_TYPES); - } - if (textValue != null && textValue.length() > 0) { - EObject component = FacesConfigFactory.eINSTANCE - .create(applicationChildClass); - // set text content. - EStructuralFeature feature = applicationChildClass - .getEStructuralFeatures().get(0); - component.eSet(feature, textValue); - return component; - } - return null; - } - - /** - * Set the <application> element as the structuredViewer's input. - * - * @param input - */ - protected void setViewerInput(Object input) { - if (input instanceof ApplicationType) { - tableViewer.setInput(input); - } else - tableViewer.setInput(null); - } - - /** - * Add a filter on the table viewer. Only the elements that is a instance of - * <code>applicationChildClass</code> could be selected. - */ - protected void configTableViewer(TableViewer tableViewer1) { - tableViewer1.addFilter(new ViewerFilter() { - public boolean select(Viewer viewer, Object parentElement, - Object element) { - return applicationChildClass.isInstance(element); - } - }); - } - - /** - * Perform some actions to create new child object and append it to the - * <application> element. - */ - void addButtonSelected(SelectionEvent e) { - /** Create such a new object. */ - EObject obj = createApplicationChildObject(); - if (obj != null) { - - boolean needRefreshAll = false; - Command command = null; - if (getInput() instanceof ApplicationType) { - /** - * The input is a <application> element and not null, append the - * new object to it. - */ - ApplicationType application = (ApplicationType) getInput(); - command = AddCommand.create(getEditingDomain(), application, - null, obj); - } else { - /** - * The input is null, create a <application> element and append - * it to <faces-config>. - */ - needRefreshAll = true; - - List list = new ArrayList(2); - ApplicationType application = FacesConfigFactory.eINSTANCE - .createApplicationType(); - Command cmd1 = AddCommand.create(getEditingDomain(), - application, null, obj); - list.add(cmd1); - Command cmd2 = AddCommand.create(getEditingDomain(), this - .getPage().getInput(), null, application); - list.add(cmd2); - command = new CompoundCommand(list); - } - - if (command.canExecute()) { - getEditingDomain().getCommandStack().execute(command); - if (needRefreshAll) { - /** reset the application input. */ - ((OthersPage) this.getPage()).resetApplicationInput(); - } - } - } - - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/AttributeSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/AttributeSection.java deleted file mode 100644 index 6a8d0fbbf..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/AttributeSection.java +++ /dev/null @@ -1,505 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.section; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.Assert; -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.common.command.CompoundCommand; -import org.eclipse.emf.edit.command.AddCommand; -import org.eclipse.emf.edit.command.RemoveCommand; -import org.eclipse.emf.edit.command.SetCommand; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jst.jsf.facesconfig.emf.AttributeClassType; -import org.eclipse.jst.jsf.facesconfig.emf.AttributeNameType; -import org.eclipse.jst.jsf.facesconfig.emf.AttributeType; -import org.eclipse.jst.jsf.facesconfig.emf.DefaultValueType; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.emf.SuggestedValueType; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.jst.jsf.facesconfig.ui.dialog.AddEditAttributeDialog; -import org.eclipse.jst.jsf.facesconfig.ui.page.IFacesConfigPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.MouseAdapter; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.widgets.FormToolkit; - -public class AttributeSection extends AbstractFacesConfigSection { - - private static final int TABLE_DEFAULT_HEIGHT = 160; - - private TableViewer tableViewer; - - private Button removeButton; - - private Button editButton; - - /** - * - * @param parent - * @param managedForm - * @param page - * @param toolkit - */ - public AttributeSection(Composite parent, IManagedForm managedForm, - IFacesConfigPage page, FormToolkit toolkit) { - super(parent, managedForm, page, toolkit, null, null); - this.getSection().setText(EditorMessages.AttributeSection_Name); - this.getSection().setDescription( - EditorMessages.AttributeSection_Description); - - } - - /** - * - */ - protected void createContents(Composite container, FormToolkit toolkit) { - GridLayout gl = new GridLayout(); - gl.horizontalSpacing = 0; - gl.marginWidth = 0; - gl.numColumns = 2; - container.setLayout(gl); - GridData td = new GridData(GridData.FILL_BOTH); - container.setLayoutData(td); - - toolkit.paintBordersFor(container); - - Composite attributeSection = toolkit.createComposite(container); - GridLayout gl2 = new GridLayout(); - gl2.horizontalSpacing = 0; - gl2.verticalSpacing = 0; - gl2.marginWidth = 0; - gl2.marginHeight = 0; - gl2.numColumns = 2; - attributeSection.setLayout(gl2); - GridData gd = new GridData(GridData.FILL_BOTH - | GridData.VERTICAL_ALIGN_BEGINNING); - attributeSection.setLayoutData(gd); - - createTableSection(attributeSection, toolkit); - createButtonsSection(attributeSection, toolkit); - - } - - /** - * create table section - * - * @param container - * @param toolkit - */ - private void createTableSection(Composite container, FormToolkit toolkit) { - Composite tableContainer = toolkit.createComposite(container); - GridData gd = new GridData(GridData.FILL_BOTH - | GridData.GRAB_HORIZONTAL); - tableContainer.setLayoutData(gd); - toolkit.paintBordersFor(tableContainer); - - GridLayout gl = new GridLayout(); - tableContainer.setLayout(gl); - - Table table = new Table(tableContainer, SWT.H_SCROLL | SWT.V_SCROLL - | SWT.FULL_SELECTION | SWT.BORDER); - gd = new GridData(GridData.FILL_BOTH); - gd.horizontalSpan = 1; - gd.heightHint = TABLE_DEFAULT_HEIGHT; - table.setLayoutData(gd); - - table.setHeaderVisible(true); - table.setLinesVisible(true); - TableLayout layout = new TableLayout(); - table.setLayout(layout); - - TableColumn nameCol = new TableColumn(table, SWT.NONE); - layout.addColumnData(new ColumnWeightData(1, true)); - nameCol - .setText(EditorMessages.AttributeSection_Table_NameColumn); - - TableColumn classCol = new TableColumn(table, SWT.NONE); - layout.addColumnData(new ColumnWeightData(1, true)); - classCol - .setText(EditorMessages.AttributeSection_Table_ClassColumn); - - TableColumn valueCol = new TableColumn(table, SWT.NONE); - layout.addColumnData(new ColumnWeightData(1, true)); - valueCol - .setText(EditorMessages.AttributeSection_Table_DefaultValueColumn); - - TableColumn suggestedValueCol = new TableColumn(table, SWT.NONE); - layout.addColumnData(new ColumnWeightData(1, true)); - suggestedValueCol - .setText(EditorMessages.AttributeSection_Table_SuggestedValueColumn); - - table.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - updateButtons(); - } - }); - - table.addMouseListener(new MouseAdapter() { - public void mouseDoubleClick(MouseEvent e) { - if (((IStructuredSelection) tableViewer.getSelection()).size() > 0) - editButtonSelected(); - } - }); - - tableViewer = new TableViewer(table); - tableViewer.setContentProvider(new AdapterFactoryContentProvider( - getAdapterFactory())); - tableViewer.setLabelProvider(new AdapterFactoryLabelProvider( - getAdapterFactory())); - - tableViewer.addFilter(new ViewerFilter() { - public boolean select(Viewer viewer, Object parentElement, - Object element) { - return FacesConfigPackage.eINSTANCE.getAttributeType() - .isInstance(element); - } - }); - - tableViewer.addSelectionChangedListener(this); - } - - /** - * Update the buttons' enable and disable status - */ - private void updateButtons() { - if (((IStructuredSelection) tableViewer.getSelection()).size() > 0) { - editButton.setEnabled(true); - removeButton.setEnabled(true); - } else { - editButton.setEnabled(false); - removeButton.setEnabled(false); - } - } - - /** - * create buttons - * - * @param container - * @param toolkit - */ - private void createButtonsSection(Composite container, FormToolkit toolkit) { - // create operation buttons's container - Composite operationContainer = toolkit.createComposite(container); - GridData gd = new GridData(GridData.FILL_VERTICAL - | GridData.VERTICAL_ALIGN_BEGINNING); - operationContainer.setLayoutData(gd); - GridLayout gl = new GridLayout(); - operationContainer.setLayout(gl); - - Button addButton = toolkit.createButton(operationContainer, - EditorMessages.UI_Button_Add_more, //$NON-NLS-1$ - SWT.PUSH); - gd = new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING); - gd.grabExcessHorizontalSpace = false; - addButton.setLayoutData(gd); - - editButton = toolkit.createButton(operationContainer, - EditorMessages.UI_Button_Edit_more, //$NON-NLS-1$ - SWT.PUSH); - gd = new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING); - gd.grabExcessHorizontalSpace = false; - editButton.setLayoutData(gd); - - removeButton = toolkit.createButton(operationContainer, - EditorMessages.UI_Button_Remove, //$NON-NLS-1$ - SWT.PUSH); - gd = new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING); - gd.grabExcessHorizontalSpace = false; - removeButton.setLayoutData(gd); - - addButton.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent e) { - addButtonSelected(); - } - - }); - - editButton.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent e) { - editButtonSelected(); - } - - }); - removeButton.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent e) { - removeButtonSelected(); - } - - }); - } - - /** - * - */ - public void refreshAll() { - tableViewer.setInput(getInput()); - updateButtons(); - - } - - /** - * - */ - public void refresh() { - super.refresh(); - tableViewer.refresh(); - updateButtons(); - } - - /** - * add an attribute. - * - */ - private void addButtonSelected() { - Shell shell = EditorPlugin.getActiveShell(); - - AddEditAttributeDialog dialog = new AddEditAttributeDialog(shell, true); - dialog.setProject((IProject) getPage().getEditor().getAdapter( - IProject.class)); - if (dialog.open() == Dialog.OK) { - - // AttributeType newAttribute = dialog.getResult(); - AttributeType newAttribute = FacesConfigFactory.eINSTANCE - .createAttributeType(); - - if (dialog.getAttributeName().length() > 0) { - AttributeNameType attributeNameType = FacesConfigFactory.eINSTANCE - .createAttributeNameType(); - attributeNameType.setTextContent(dialog.getAttributeName()); - newAttribute.setAttributeName(attributeNameType); - } - - if (dialog.getAttributeClass().length() > 0) { - AttributeClassType attributeClassType = FacesConfigFactory.eINSTANCE - .createAttributeClassType(); - attributeClassType.setTextContent(dialog.getAttributeClass()); - newAttribute.setAttributeClass(attributeClassType); - } - - if (dialog.getDefaultValue().length() > 0) { - DefaultValueType defaultValueType = FacesConfigFactory.eINSTANCE - .createDefaultValueType(); - defaultValueType.setTextContent(dialog.getDefaultValue()); - newAttribute.setDefaultValue(defaultValueType); - } - - if (dialog.getSuggestedValue().length() > 0) { - SuggestedValueType suggestedValueType = FacesConfigFactory.eINSTANCE - .createSuggestedValueType(); - suggestedValueType.setTextContent(dialog.getSuggestedValue()); - newAttribute.setSuggestedValue(suggestedValueType); - } - - Command addCommand = AddCommand.create(this.getEditingDomain(), - getInput(), null, newAttribute); // getEReference(), - // newAttribute); - if (addCommand.canExecute()) { - this.getEditingDomain().getCommandStack().execute(addCommand); - - } - } - - } - - /** - * edit an attribute. - * - */ - private void editButtonSelected() { - - AttributeType attribute = (AttributeType) ((IStructuredSelection) tableViewer - .getSelection()).getFirstElement(); - - Assert.isNotNull(attribute); - - Shell shell = EditorPlugin.getActiveShell(); - - AddEditAttributeDialog dialog = new AddEditAttributeDialog(shell, false); - dialog.setProject((IProject) getPage().getEditor().getAdapter( - IProject.class)); - if (attribute.getAttributeName() != null) { - dialog.setAttributeName(attribute.getAttributeName() - .getTextContent()); - } - - if (attribute.getAttributeClass() != null) { - dialog.setAttributeClass(attribute.getAttributeClass() - .getTextContent()); - } - - if (attribute.getDefaultValue() != null) { - dialog - .setDefaultValue(attribute.getDefaultValue() - .getTextContent()); - } - - if (attribute.getSuggestedValue() != null) { - dialog.setSuggestedValue(attribute.getSuggestedValue() - .getTextContent()); - } - - if (dialog.open() == Dialog.OK) { - List commands = new ArrayList(4); - - if (attribute.getAttributeName() != null) { - Command cmd1 = SetCommand.create(this.getEditingDomain(), - attribute.getAttributeName(), - FacesConfigPackage.eINSTANCE - .getAttributeNameType_TextContent(), dialog - .getAttributeName()); - commands.add(cmd1); - } else if (dialog.getAttributeName().length() > 0) { - AttributeNameType attributeNameType = FacesConfigFactory.eINSTANCE - .createAttributeNameType(); - attributeNameType.setTextContent(dialog.getAttributeName()); - - Command cmd2 = AddCommand.create(this.getEditingDomain(), - attribute, FacesConfigPackage.eINSTANCE - .getAttributeType_AttributeName(), - attributeNameType); - commands.add(cmd2); - } - - if (attribute.getAttributeClass() != null) { - Command cmd3 = SetCommand.create(this.getEditingDomain(), - attribute.getAttributeClass(), - FacesConfigPackage.eINSTANCE - .getAttributeClassType_TextContent(), dialog - .getAttributeClass()); - commands.add(cmd3); - } else if (dialog.getAttributeClass().length() > 0) { - AttributeClassType attributeClassType = FacesConfigFactory.eINSTANCE - .createAttributeClassType(); - attributeClassType.setTextContent(dialog.getAttributeClass()); - - Command cmd4 = AddCommand.create(this.getEditingDomain(), - attribute, FacesConfigPackage.eINSTANCE - .getAttributeType_AttributeClass(), - attributeClassType); - commands.add(cmd4); - } - - if (attribute.getDefaultValue() != null) { - Command cmd5 = SetCommand.create(this.getEditingDomain(), - attribute.getDefaultValue(), - FacesConfigPackage.eINSTANCE - .getDefaultValueType_TextContent(), dialog - .getDefaultValue()); - commands.add(cmd5); - - } else if (dialog.getDefaultValue().length() > 0) { - DefaultValueType defaultValueType = FacesConfigFactory.eINSTANCE - .createDefaultValueType(); - defaultValueType.setTextContent(dialog.getDefaultValue()); - Command cmd6 = AddCommand.create(this.getEditingDomain(), - attribute, FacesConfigPackage.eINSTANCE - .getAttributeType_DefaultValue(), - defaultValueType); - commands.add(cmd6); - } - - if (attribute.getSuggestedValue() != null) { - Command cmd7 = SetCommand.create(this.getEditingDomain(), - attribute.getSuggestedValue(), - FacesConfigPackage.eINSTANCE - .getSuggestedValueType_TextContent(), dialog - .getSuggestedValue()); - commands.add(cmd7); - } else if (dialog.getSuggestedValue().length() > 0) { - SuggestedValueType suggestedValueType = FacesConfigFactory.eINSTANCE - .createSuggestedValueType(); - suggestedValueType.setTextContent(dialog.getSuggestedValue()); - Command cmd8 = AddCommand.create(this.getEditingDomain(), - attribute, FacesConfigPackage.eINSTANCE - .getAttributeType_SuggestedValue(), - suggestedValueType); - commands.add(cmd8); - } - - CompoundCommand command = new CompoundCommand(commands); - if (command.canExecute()) { - this.getEditingDomain().getCommandStack().execute(command); - tableViewer.refresh(attribute); - - } - } - - } - - /** - * remove an attribute. - * - */ - private void removeButtonSelected() { - AttributeType attribute = (AttributeType) ((IStructuredSelection) tableViewer - .getSelection()).getFirstElement(); - - Assert.isNotNull(attribute); - - Command removeCommand = RemoveCommand.create(this.getEditingDomain(), - getInput(), null, attribute);// getEReference(), attribute); - - if (removeCommand.canExecute()) { - this.getEditingDomain().getCommandStack().execute(removeCommand); - refreshAll(); - } - - } - - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection() - */ - public ISelection getSelection() { - return tableViewer.getSelection(); - } - - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection) - */ - public void setSelection(ISelection selection) { - - tableViewer.setSelection(selection); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ComponentGeneralSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ComponentGeneralSection.java deleted file mode 100644 index 9c0f27eb6..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ComponentGeneralSection.java +++ /dev/null @@ -1,403 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.section; - -import org.eclipse.core.resources.IProject; -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.impl.AdapterImpl; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.emf.edit.command.AddCommand; -import org.eclipse.emf.edit.command.SetCommand; -import org.eclipse.emf.edit.domain.EditingDomain; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.ClassButtonDialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.IDialogFieldApplyListener; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.LayoutUtil; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.StringDialogField; -import org.eclipse.jst.jsf.facesconfig.emf.ComponentClassType; -import org.eclipse.jst.jsf.facesconfig.emf.ComponentType; -import org.eclipse.jst.jsf.facesconfig.emf.ComponentTypeType; -import org.eclipse.jst.jsf.facesconfig.emf.DescriptionType; -import org.eclipse.jst.jsf.facesconfig.emf.DisplayNameType; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.jst.jsf.facesconfig.ui.IFacesConfigConstants; -import org.eclipse.jst.jsf.facesconfig.ui.page.IFacesConfigPage; -import org.eclipse.jst.jsf.facesconfig.ui.util.ModelUtil; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * The sections that used for displaying and editing the general information of - * a component, the information includs display name, description, component - * type and component class. - * - * @author sfshi - * - */ -public class ComponentGeneralSection extends AbstractFacesConfigSection { - - private StringDialogField displayNameField; - - private StringDialogField descriptionField; - - private StringDialogField componentTypeField; - - private ClassButtonDialogField componentClassField; - - private ComponentGeneralAdapter componentGeneralAdapter; - - /** - * - * @param parent - * @param managedForm - * @param page - * @param toolkit - */ - public ComponentGeneralSection(Composite parent, IManagedForm managedForm, - IFacesConfigPage page, FormToolkit toolkit) { - super(parent, managedForm, page, toolkit, null, null); - getSection() - .setText(EditorMessages.ComponentGeneralSection_Name); - getSection().setDescription( - EditorMessages.ComponentGeneralSection_Description); - } - - /** - * Create the UI fields. - */ - protected void createContents(Composite container, FormToolkit toolkit) { - int numberOfColumns = 4; - GridLayout layout = new GridLayout(numberOfColumns, false); - container.setLayout(layout); - GridData td = new GridData(GridData.FILL_HORIZONTAL); - container.setLayoutData(td); - - toolkit.paintBordersFor(container); - displayNameField = new StringDialogField(); - displayNameField - .setLabelText(EditorMessages.ComponentGeneralSection_Label_DisplayName); - displayNameField.doFillIntoGrid(toolkit, container, numberOfColumns); - - displayNameField - .setDialogFieldApplyListener(new IDialogFieldApplyListener() { - - public void dialogFieldApplied(DialogField field) { - String newDisplayNameValue = ((StringDialogField) field) - .getText().trim(); - Command cmd = null; - ComponentType component = (ComponentType) getInput(); - EditingDomain editingDomain = getEditingDomain(); - if (component.getDisplayName().size() > 0) { - DisplayNameType displayName = (DisplayNameType) component - .getDisplayName().get(0); - cmd = SetCommand.create(editingDomain, displayName, - FacesConfigPackage.eINSTANCE - .getDisplayNameType_TextContent(), - newDisplayNameValue); - } else { - DisplayNameType displayNameType = FacesConfigFactory.eINSTANCE - .createDisplayNameType(); - displayNameType.setTextContent(newDisplayNameValue); - - /** For the new displayname object, add the adapter. */ - displayNameType.eAdapters().add( - getComponentGeneralAdapter()); - cmd = AddCommand.create(editingDomain, component, - FacesConfigPackage.eINSTANCE - .getComponentType_DisplayName(), - displayNameType); - } - if (cmd.canExecute()) { - editingDomain.getCommandStack().execute(cmd); - } - } - - }); - - descriptionField = new StringDialogField(2); - descriptionField - .setLabelText(EditorMessages.ComponentGeneralSection_Label_Description); - descriptionField.doFillIntoGrid(toolkit, container, numberOfColumns); - - descriptionField - .setDialogFieldApplyListener(new IDialogFieldApplyListener() { - public void dialogFieldApplied(DialogField field) { - String newDescriptionValue = ((StringDialogField) field) - .getText().trim(); - - newDescriptionValue = ModelUtil - .escapeEntities(newDescriptionValue); - Command cmd = null; - ComponentType component = (ComponentType) getInput(); - EditingDomain editingDomain = getEditingDomain(); - if (component.getDescription().size() > 0) { - DescriptionType description = (DescriptionType) component - .getDescription().get(0); - cmd = SetCommand.create(editingDomain, description, - FacesConfigPackage.eINSTANCE - .getDescriptionType_TextContent(), - newDescriptionValue); - } else { - DescriptionType description = FacesConfigFactory.eINSTANCE - .createDescriptionType(); - description.setTextContent(newDescriptionValue); - /** For the new description object, add the adapter. */ - description.eAdapters().add( - getComponentGeneralAdapter()); - - cmd = AddCommand.create(editingDomain, component, - FacesConfigPackage.eINSTANCE - .getComponentType_Description(), - description); - } - if (cmd.canExecute()) { - editingDomain.getCommandStack().execute(cmd); - } - } - }); - - componentTypeField = new StringDialogField(); - componentTypeField - .setLabelText(EditorMessages.ComponentGeneralSection_Label_ComponentType); - componentTypeField.doFillIntoGrid(toolkit, container, numberOfColumns); - componentTypeField - .setDialogFieldApplyListener(new IDialogFieldApplyListener() { - public void dialogFieldApplied(DialogField field) { - ComponentTypeType componentType = FacesConfigFactory.eINSTANCE - .createComponentTypeType(); - componentType - .setTextContent(((StringDialogField) field) - .getText()); - - EditingDomain editingDomain = getEditingDomain(); - if (editingDomain != null) { - Command command = SetCommand.create(editingDomain, - getInput(), FacesConfigPackage.eINSTANCE - .getComponentType_ComponentType(), - componentType); - if (command.canExecute()) { - editingDomain.getCommandStack() - .execute(command); - } - } - } - }); - - componentClassField = new ClassButtonDialogField(null); - componentClassField - .setLabelText(EditorMessages.ComponentGeneralSection_Label_ComponentClass); - componentClassField.doFillIntoGrid(toolkit, container, numberOfColumns); - LayoutUtil.setHorizontalGrabbing(componentClassField.getTextControl( - toolkit, container)); - componentClassField.setProject((IProject) getPage().getEditor() - .getAdapter(IProject.class)); - componentClassField - .setDialogFieldApplyListener(new IDialogFieldApplyListener() { - public void dialogFieldApplied(DialogField field) { - - ComponentClassType componentClass = FacesConfigFactory.eINSTANCE - .createComponentClassType(); - componentClass - .setTextContent(((StringDialogField) field) - .getText()); - EditingDomain editingDomain = getEditingDomain(); - if (editingDomain != null) { - Command command = SetCommand.create(editingDomain, - getInput(), FacesConfigPackage.eINSTANCE - .getComponentType_ComponentClass(), - componentClass); - if (command.canExecute()) { - editingDomain.getCommandStack() - .execute(command); - } - } - - } - }); - componentClassField - .setSuperClassName(IFacesConfigConstants.COMPONENT_SUPER_CLASS); - } - - /** - * - */ - public void refreshAll() { - refresh(); - } - - /** - * Refresh the content on this section. - */ - public void refresh() { - super.refresh(); - Object input = this.getInput(); - if (input instanceof ComponentType) { - ComponentType component = (ComponentType) input; - - if (component.getDisplayName().size() > 0) { - DisplayNameType displayName = (DisplayNameType) component - .getDisplayName().get(0); - displayNameField.setTextWithoutUpdate(displayName - .getTextContent()); - } else { - displayNameField.setTextWithoutUpdate(""); - } - - if (component.getDescription().size() > 0) { - DescriptionType description = (DescriptionType) component - .getDescription().get(0); - String descriptionString = description.getTextContent(); - descriptionString = ModelUtil.unEscapeEntities(descriptionString); - descriptionField.setTextWithoutUpdate(descriptionString); - } else { - descriptionField.setTextWithoutUpdate(""); - } - - if (component.getComponentType() != null) { - componentTypeField.setTextWithoutUpdate(component - .getComponentType().getTextContent()); - } else { - componentTypeField.setTextWithoutUpdate(""); - } - - if (component.getComponentClass() != null) { - componentClassField.setTextWithoutUpdate(component - .getComponentClass().getTextContent()); - } else { - componentClassField.setTextWithoutUpdate(""); - } - } - } - - /** - * Add ComponentGeneralAdapter onto <component> and the first <display-name> - * and <description> elements. - */ - protected void addAdaptersOntoInput(Object newInput) { - ComponentType component = (ComponentType) newInput; - if (EcoreUtil.getExistingAdapter(component, - ComponentGeneralSection.class) == null) { - - component.eAdapters().add(getComponentGeneralAdapter()); - } - - if (component.getDisplayName().size() > 0) { - DisplayNameType displayName = (DisplayNameType) component - .getDisplayName().get(0); - if (EcoreUtil.getExistingAdapter(displayName, - ComponentGeneralSection.class) == null) { - - displayName.eAdapters().add(getComponentGeneralAdapter()); - } - } - - if (component.getDescription().size() > 0) { - DescriptionType description = (DescriptionType) component - .getDescription().get(0); - if (EcoreUtil.getExistingAdapter(description, - ComponentGeneralSection.class) == null) { - - description.eAdapters().add(getComponentGeneralAdapter()); - } - } - } - - /** - * Remove ComponentGeneralAdapter from <component> and the first - * <display-name> and <description> elements. - */ - protected void removeAdaptersFromInput(Object oldInput) { - ComponentType component = (ComponentType) oldInput; - if (EcoreUtil.getExistingAdapter(component, - ComponentGeneralSection.class) != null) { - component.eAdapters().remove(getComponentGeneralAdapter()); - } - if (component.getDisplayName().size() > 0) { - DisplayNameType displayName = (DisplayNameType) component - .getDisplayName().get(0); - if (EcoreUtil.getExistingAdapter(displayName, - ComponentGeneralSection.class) != null) { - - displayName.eAdapters().remove(getComponentGeneralAdapter()); - } - } - - if (component.getDescription().size() > 0) { - DescriptionType description = (DescriptionType) component - .getDescription().get(0); - if (EcoreUtil.getExistingAdapter(description, - ComponentGeneralSection.class) != null) { - - description.eAdapters().remove(getComponentGeneralAdapter()); - } - } - } - - /** - * - * @return - */ - private Adapter getComponentGeneralAdapter() { - - if (componentGeneralAdapter == null) { - componentGeneralAdapter = new ComponentGeneralAdapter(); - } - return componentGeneralAdapter; - } - - /** - * The adapter that will be added onto <component> element, to listen the - * events of the children that are displayed in this section, notify the - * section to refresh. - * - * @author sfshi - * - */ - class ComponentGeneralAdapter extends AdapterImpl { - - public boolean isAdapterForType(Object type) { - if (type == ComponentGeneralSection.class) - return true; - return false; - } - - public void notifyChanged(Notification msg) { - - if (msg.getEventType() == Notification.ADD - || msg.getEventType() == Notification.REMOVE - || msg.getEventType() == Notification.SET) { - if (msg.getFeature() == FacesConfigPackage.eINSTANCE - .getComponentType_ComponentClass() - || msg.getFeature() == FacesConfigPackage.eINSTANCE - .getComponentType_ComponentType() - || msg.getFeature() == FacesConfigPackage.eINSTANCE - .getComponentType_DisplayName() - || msg.getFeature() == FacesConfigPackage.eINSTANCE - .getComponentType_Description()) { - refresh(); - } else if (msg.getFeature() == FacesConfigPackage.eINSTANCE - .getDisplayNameType_TextContent() - || msg.getFeature() == FacesConfigPackage.eINSTANCE - .getDescriptionType_TextContent()) { - refresh(); - } - } - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ComponentMasterSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ComponentMasterSection.java deleted file mode 100644 index 551b85f95..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ComponentMasterSection.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.section; - -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.edit.command.AddCommand; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jst.jsf.facesconfig.emf.ComponentType; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.jst.jsf.facesconfig.ui.page.FacesConfigMasterDetailPage; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * - * @author sfshi - * - */ -public class ComponentMasterSection extends FacesConfigMasterSection { - - /** - * - * @param parent - * @param managedForm - * @param toolkit - * @param page - */ - public ComponentMasterSection(Composite parent, IManagedForm managedForm, - FormToolkit toolkit, FacesConfigMasterDetailPage page) { - super(parent, managedForm, toolkit, page, null, null); - getSection().setText(EditorMessages.ComponentMasterSection_Name); //$NON-NLS-1$ - getSection().setDescription( - EditorMessages.ComponentMasterSection_Description); - } - - /** - * Config the table viwer, set a filter for it, only the object of - * ComponentType will be selected. - */ - protected void configViewer(StructuredViewer structuredViewer) { - super.configViewer(structuredViewer); - structuredViewer.addFilter(new ViewerFilter() { - public boolean select(Viewer viewer, Object parentElement, - Object element) { - return FacesConfigPackage.eINSTANCE.getComponentType() - .isInstance(element); - } - }); - - } - - /** - * Create a new component. - */ - protected void addButtonSelected(SelectionEvent e) { - ComponentType component = FacesConfigFactory.eINSTANCE - .createComponentType(); - - Command command = AddCommand.create(getEditingDomain(), - this.getInput(), FacesConfigPackage.eINSTANCE - .getFacesConfigType_Component(), component); - - if (command.canExecute()) { - getEditingDomain().getCommandStack().execute(command); - IStructuredSelection selection = new StructuredSelection(component); - getStructuredViewer().refresh(); - getStructuredViewer().setSelection(selection); - } - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ConverterGeneralSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ConverterGeneralSection.java deleted file mode 100644 index baf609737..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ConverterGeneralSection.java +++ /dev/null @@ -1,472 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.section; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.common.command.CompoundCommand; -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.impl.AdapterImpl; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.emf.edit.command.AddCommand; -import org.eclipse.emf.edit.command.SetCommand; -import org.eclipse.emf.edit.domain.EditingDomain; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.ClassButtonDialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.IDialogFieldApplyListener; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.LayoutUtil; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.StringDialogField; -import org.eclipse.jst.jsf.facesconfig.emf.ConverterClassType; -import org.eclipse.jst.jsf.facesconfig.emf.ConverterForClassType; -import org.eclipse.jst.jsf.facesconfig.emf.ConverterIdType; -import org.eclipse.jst.jsf.facesconfig.emf.ConverterType; -import org.eclipse.jst.jsf.facesconfig.emf.DescriptionType; -import org.eclipse.jst.jsf.facesconfig.emf.DisplayNameType; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.jst.jsf.facesconfig.ui.IFacesConfigConstants; -import org.eclipse.jst.jsf.facesconfig.ui.page.IFacesConfigPage; -import org.eclipse.jst.jsf.facesconfig.ui.util.ModelUtil; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * @author Bryan Yang - * - */ -public class ConverterGeneralSection extends AbstractFacesConfigSection { - - private StringDialogField displayNameField; - - private StringDialogField descriptionField; - - private StringDialogField converterIdField; - - private ClassButtonDialogField converterForClassField; - - private ClassButtonDialogField converterClassField; - - private ConverterGeneralAdapter converterGeneralAdapter; - - /** - * - * @param parent - * @param managedForm - * @param page - * @param toolkit - */ - public ConverterGeneralSection(Composite parent, IManagedForm managedForm, - IFacesConfigPage page, FormToolkit toolkit) { - super(parent, managedForm, page, toolkit, null, null); - getSection() - .setText(EditorMessages.ConverterGeneralSection_Name); - getSection().setDescription( - EditorMessages.ConverterGeneralSection_Description); - } - - /** - * - */ - protected void createContents(Composite container, FormToolkit toolkit) { - int numberOfColumns = 4; - GridLayout layout = new GridLayout(numberOfColumns, false); - container.setLayout(layout); - GridData td = new GridData(GridData.FILL_HORIZONTAL); - container.setLayoutData(td); - - toolkit.paintBordersFor(container); - displayNameField = new StringDialogField(); - displayNameField - .setLabelText(EditorMessages.ConverterGeneralSection_Label_DisplayName); - displayNameField.doFillIntoGrid(toolkit, container, numberOfColumns); - - displayNameField - .setDialogFieldApplyListener(new IDialogFieldApplyListener() { - - public void dialogFieldApplied(DialogField field) { - String newDisplayNameValue = ((StringDialogField) field) - .getText().trim(); - Command cmd = null; - ConverterType Converter = (ConverterType) getInput(); - EditingDomain editingDomain = getEditingDomain(); - if (Converter.getDisplayName().size() > 0) { - DisplayNameType displayName = (DisplayNameType) Converter - .getDisplayName().get(0); - cmd = SetCommand.create(editingDomain, displayName, - FacesConfigPackage.eINSTANCE - .getDisplayNameType_TextContent(), - newDisplayNameValue); - } else { - DisplayNameType displayNameType = FacesConfigFactory.eINSTANCE - .createDisplayNameType(); - displayNameType.setTextContent(newDisplayNameValue); - - displayNameType.eAdapters().add( - getConverterGeneralAdapter()); - cmd = AddCommand.create(editingDomain, Converter, - FacesConfigPackage.eINSTANCE - .getConverterType_DisplayName(), - displayNameType); - } - if (cmd.canExecute()) { - editingDomain.getCommandStack().execute(cmd); - } - } - - }); - - descriptionField = new StringDialogField(2); - descriptionField - .setLabelText(EditorMessages.ConverterGeneralSection_Label_Description); - descriptionField.doFillIntoGrid(toolkit, container, numberOfColumns); - - descriptionField - .setDialogFieldApplyListener(new IDialogFieldApplyListener() { - public void dialogFieldApplied(DialogField field) { - String newDescriptionValue = ((StringDialogField) field) - .getText().trim(); - - newDescriptionValue = ModelUtil - .escapeEntities(newDescriptionValue); - Command cmd = null; - ConverterType Converter = (ConverterType) getInput(); - EditingDomain editingDomain = getEditingDomain(); - if (Converter.getDescription().size() > 0) { - DescriptionType description = (DescriptionType) Converter - .getDescription().get(0); - cmd = SetCommand.create(editingDomain, description, - FacesConfigPackage.eINSTANCE - .getDescriptionType_TextContent(), - newDescriptionValue); - } else { - DescriptionType description = FacesConfigFactory.eINSTANCE - .createDescriptionType(); - description.setTextContent(newDescriptionValue); - - description.eAdapters().add( - getConverterGeneralAdapter()); - cmd = AddCommand.create(editingDomain, Converter, - FacesConfigPackage.eINSTANCE - .getConverterType_Description(), - description); - } - if (cmd.canExecute()) { - editingDomain.getCommandStack().execute(cmd); - } - } - }); - - converterIdField = new StringDialogField(); - // converterIdField.setRequired(true); - converterIdField - .setLabelText(EditorMessages.ConverterGeneralSection_Label_ConverterID); - converterIdField.doFillIntoGrid(toolkit, container, numberOfColumns); - converterIdField - .setDialogFieldApplyListener(new IDialogFieldApplyListener() { - public void dialogFieldApplied(DialogField field) { - ConverterIdType converterIdType = FacesConfigFactory.eINSTANCE - .createConverterIdType(); - - converterIdType - .setTextContent(((StringDialogField) field) - .getText()); - - EditingDomain editingDomain = getEditingDomain(); - List commands = new ArrayList(2); - Command cmd1 = SetCommand.create(editingDomain, - getInput(), FacesConfigPackage.eINSTANCE - .getConverterType_ConverterForClass(), - SetCommand.UNSET_VALUE); - commands.add(cmd1); - Command cmd2 = SetCommand.create(editingDomain, - getInput(), FacesConfigPackage.eINSTANCE - .getConverterType_ConverterId(), - converterIdType); - commands.add(cmd2); - Command command = new CompoundCommand(commands); - if (editingDomain != null) { - if (command.canExecute()) { - editingDomain.getCommandStack() - .execute(command); - refresh(); - } - } - } - }); - - converterForClassField = new ClassButtonDialogField(null); - // converterForClassField.setRequired(true); - converterForClassField - .setLabelText(EditorMessages.ConverterGeneralSection_Label_ConverterForClass); - converterForClassField.setProject((IProject) getPage().getEditor() - .getAdapter(IProject.class)); - converterForClassField.doFillIntoGrid(toolkit, container, - numberOfColumns); - LayoutUtil.setHorizontalGrabbing(converterForClassField.getTextControl( - toolkit, container)); - - converterForClassField - .setDialogFieldApplyListener(new IDialogFieldApplyListener() { - public void dialogFieldApplied(DialogField field) { - - ConverterForClassType converterForClass = FacesConfigFactory.eINSTANCE - .createConverterForClassType(); - converterForClass - .setTextContent(((StringDialogField) field) - .getText()); - EditingDomain editingDomain = getEditingDomain(); - List commands = new ArrayList(2); - Command cmd1 = SetCommand.create(editingDomain, - getInput(), FacesConfigPackage.eINSTANCE - .getConverterType_ConverterId(), - SetCommand.UNSET_VALUE); - commands.add(cmd1); - Command cmd2 = SetCommand.create(editingDomain, - getInput(), FacesConfigPackage.eINSTANCE - .getConverterType_ConverterForClass(), - converterForClass); - commands.add(cmd2); - Command command = new CompoundCommand(commands); - if (editingDomain != null) { - if (command.canExecute()) { - editingDomain.getCommandStack() - .execute(command); - refresh(); - } - } - - } - }); - - converterClassField = new ClassButtonDialogField(null); - // converterClassField.setRequired(true); - converterClassField - .setLabelText(EditorMessages.ConverterGeneralSection_Label_ConverterClass); - converterClassField.setProject((IProject) getPage().getEditor() - .getAdapter(IProject.class)); - converterClassField.doFillIntoGrid(toolkit, container, numberOfColumns); - LayoutUtil.setHorizontalGrabbing(converterClassField.getTextControl( - toolkit, container)); - - converterClassField - .setDialogFieldApplyListener(new IDialogFieldApplyListener() { - public void dialogFieldApplied(DialogField field) { - - ConverterClassType ConverterClass = FacesConfigFactory.eINSTANCE - .createConverterClassType(); - ConverterClass - .setTextContent(((StringDialogField) field) - .getText()); - EditingDomain editingDomain = getEditingDomain(); - if (editingDomain != null) { - Command command = SetCommand.create(editingDomain, - getInput(), FacesConfigPackage.eINSTANCE - .getConverterType_ConverterClass(), - ConverterClass); - if (command.canExecute()) { - editingDomain.getCommandStack() - .execute(command); - } - } - - } - }); - converterClassField - .setInterface(IFacesConfigConstants.CONVERTER_INTERFACE); - } - - /** - * - */ - public void refreshAll() { - refresh(); - } - - /** - * - */ - public void refresh() { - super.refresh(); - Object input = this.getInput(); - if (input instanceof ConverterType) { - ConverterType Converter = (ConverterType) input; - - if (Converter.getDisplayName().size() > 0) { - DisplayNameType displayName = (DisplayNameType) Converter - .getDisplayName().get(0); - displayNameField.setTextWithoutUpdate(displayName - .getTextContent()); - } else { - displayNameField.setTextWithoutUpdate(""); - } - - if (Converter.getDescription().size() > 0) { - DescriptionType description = (DescriptionType) Converter - .getDescription().get(0); - String descriptionString = description.getTextContent(); - descriptionString = ModelUtil - .unEscapeEntities(descriptionString); - descriptionField.setTextWithoutUpdate(descriptionString); - } else { - descriptionField.setTextWithoutUpdate(""); - } - - if (Converter.getConverterId() != null) { - converterIdField.setTextWithoutUpdate(Converter - .getConverterId().getTextContent()); - } else { - converterIdField.setTextWithoutUpdate(""); - } - - if (Converter.getConverterForClass() != null) { - converterForClassField.setTextWithoutUpdate(Converter - .getConverterForClass().getTextContent()); - } else { - converterForClassField.setTextWithoutUpdate(""); - } - - if (Converter.getConverterClass() != null) { - converterClassField.setTextWithoutUpdate(Converter - .getConverterClass().getTextContent()); - } else { - converterClassField.setTextWithoutUpdate(""); - } - - } - } - - /** - * Add ConverterGeneralAdapter onto <converter> and the first <display-name> - * and <description> elements. - */ - protected void addAdaptersOntoInput(Object newInput) { - ConverterType converter = (ConverterType) newInput; - if (EcoreUtil.getExistingAdapter(converter, - ConverterGeneralSection.class) == null) { - - converter.eAdapters().add(getConverterGeneralAdapter()); - } - - if (converter.getDisplayName().size() > 0) { - DisplayNameType displayName = (DisplayNameType) converter - .getDisplayName().get(0); - if (EcoreUtil.getExistingAdapter(displayName, - ConverterGeneralSection.class) == null) { - - displayName.eAdapters().add(getConverterGeneralAdapter()); - } - } - - if (converter.getDescription().size() > 0) { - DescriptionType description = (DescriptionType) converter - .getDescription().get(0); - if (EcoreUtil.getExistingAdapter(description, - ConverterGeneralSection.class) == null) { - - description.eAdapters().add(getConverterGeneralAdapter()); - } - } - } - - /** - * Remove ConverterGeneralAdapter from <converter> and the first - * <display-name> and <description> elements. - */ - protected void removeAdaptersFromInput(Object oldInput) { - ConverterType converter = (ConverterType) oldInput; - if (EcoreUtil.getExistingAdapter(converter, - ConverterGeneralSection.class) != null) { - converter.eAdapters().remove(getConverterGeneralAdapter()); - } - if (converter.getDisplayName().size() > 0) { - DisplayNameType displayName = (DisplayNameType) converter - .getDisplayName().get(0); - if (EcoreUtil.getExistingAdapter(displayName, - ConverterGeneralSection.class) != null) { - - displayName.eAdapters().remove(getConverterGeneralAdapter()); - } - } - - if (converter.getDescription().size() > 0) { - DescriptionType description = (DescriptionType) converter - .getDescription().get(0); - if (EcoreUtil.getExistingAdapter(description, - ConverterGeneralSection.class) != null) { - - description.eAdapters().remove(getConverterGeneralAdapter()); - } - } - } - - /** - * - * @return - */ - private Adapter getConverterGeneralAdapter() { - - if (converterGeneralAdapter == null) { - converterGeneralAdapter = new ConverterGeneralAdapter(); - } - return converterGeneralAdapter; - } - - /** - * The adapter that will be added onto <converter> element, to listen the - * events of the children that are displayed in this section, notify the - * section to refresh. - * - * @author sfshi - * - */ - class ConverterGeneralAdapter extends AdapterImpl { - - public boolean isAdapterForType(Object type) { - if (type == ConverterGeneralSection.class) - return true; - return false; - } - - public void notifyChanged(Notification msg) { - - if (msg.getEventType() == Notification.ADD - || msg.getEventType() == Notification.REMOVE - || msg.getEventType() == Notification.SET) { - if (msg.getFeature() == FacesConfigPackage.eINSTANCE - .getConverterType_ConverterId() - || msg.getFeature() == FacesConfigPackage.eINSTANCE - .getConverterType_ConverterClass() - || msg.getFeature() == FacesConfigPackage.eINSTANCE - .getConverterType_ConverterForClass() - || msg.getFeature() == FacesConfigPackage.eINSTANCE - .getConverterType_Description() - || msg.getFeature() == FacesConfigPackage.eINSTANCE - .getConverterType_DisplayName()) { - refresh(); - } else if (msg.getFeature() == FacesConfigPackage.eINSTANCE - .getDisplayNameType_TextContent() - || msg.getFeature() == FacesConfigPackage.eINSTANCE - .getDescriptionType_TextContent()) { - refresh(); - } - } - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ConverterMasterSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ConverterMasterSection.java deleted file mode 100644 index 054fff77c..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ConverterMasterSection.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.section; - -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.edit.command.AddCommand; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jst.jsf.facesconfig.emf.ConverterType; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.jst.jsf.facesconfig.ui.page.FacesConfigMasterDetailPage; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * @author Bryan Yang - * - */ -public class ConverterMasterSection extends FacesConfigMasterSection { - - /** - * - * @param parent - * @param managedForm - * @param toolkit - * @param page - */ - public ConverterMasterSection(Composite parent, IManagedForm managedForm, - FormToolkit toolkit, FacesConfigMasterDetailPage page) { - super(parent, managedForm, toolkit, page, null, null); - getSection().setText(EditorMessages.ConverterMasterSection_Name); //$NON-NLS-1$ - getSection().setDescription( - EditorMessages.ConverterMasterSection_Description); - } - - /** - * Config the table viwer, set a filter for it, only the object of - * ConverterType will be selected. - */ - protected void configViewer(StructuredViewer structuredViewer) { - super.configViewer(structuredViewer); - structuredViewer.addFilter(new ViewerFilter() { - public boolean select(Viewer viewer, Object parentElement, - Object element) { - return FacesConfigPackage.eINSTANCE.getConverterType() - .isInstance(element); - } - }); - - } - - /** - * Create a new Converter. - */ - protected void addButtonSelected(SelectionEvent e) { - ConverterType Converter = FacesConfigFactory.eINSTANCE - .createConverterType(); - - Command command = AddCommand.create(getEditingDomain(), - this.getInput(), FacesConfigPackage.eINSTANCE - .getFacesConfigType_Converter(), Converter); - - if (command.canExecute()) { - getEditingDomain().getCommandStack().execute(command); - IStructuredSelection selection = new StructuredSelection(Converter); - getStructuredViewer().refresh(); - getStructuredViewer().setSelection(selection); - } - } - -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/FacesConfigMasterSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/FacesConfigMasterSection.java deleted file mode 100644 index baa845c72..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/FacesConfigMasterSection.java +++ /dev/null @@ -1,320 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.section; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.common.command.CompoundCommand; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.edit.command.RemoveCommand; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.jst.jsf.facesconfig.ui.page.FacesConfigMasterDetailPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * An default implementation of AbstractFacesConfigSection for Master Section. - * - * @author sfshi - * - */ -public abstract class FacesConfigMasterSection extends AbstractFacesConfigSection { - - private StructuredViewer structuredViewer; - - private Button removeButton; - - /** - * - * @param parent - * @param managedForm - * @param toolkit - * @param page - * @param helpContextId - * @param helpTooltip - */ - public FacesConfigMasterSection(Composite parent, IManagedForm managedForm, - FormToolkit toolkit, FacesConfigMasterDetailPage page, - String helpContextId, String helpTooltip) { - super(parent, managedForm, page, toolkit, helpContextId, helpTooltip); - } - - /** - * - */ - protected void createContents(Composite container, FormToolkit toolkit) { - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - layout.marginWidth = layout.marginHeight = 5; - container.setLayout(layout); - structuredViewer = createViewer(container, toolkit); - structuredViewer.addSelectionChangedListener(this); - createOperationSection(container, toolkit); - } - - /** - * Create the structured viewer, set up content & label provider for it. - * Defaultly create a tableviewer. - * - * @param parent - * @param toolkit - * @return the structured viewer - */ - protected StructuredViewer createViewer(Composite parent, - FormToolkit toolkit) { - Composite tableContainer = toolkit.createComposite(parent); - toolkit.paintBordersFor(tableContainer); - - GridData gd = new GridData(GridData.FILL_BOTH); - gd.heightHint = 200; - tableContainer.setLayoutData(gd); - GridLayout layout = new GridLayout(); - tableContainer.setLayout(layout); - - TableViewer tableViewer = new TableViewer(tableContainer, SWT.SINGLE - | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); - gd = new GridData(GridData.FILL_BOTH); - tableViewer.getControl().setLayoutData(gd); - - tableViewer.setContentProvider(new AdapterFactoryContentProvider( - getAdapterFactory())); - tableViewer.setLabelProvider(new AdapterFactoryLabelProvider( - getAdapterFactory())); - - configViewer(tableViewer); - - return tableViewer; - } - - /** - * Config the viewer, such as set a filter and so on. Sub classes should - * override this method to add filter. - * - * @param viewer - */ - protected void configViewer(StructuredViewer viewer) { - // do nothing; subs may override - } - - /** - * Defaultly we create a "New" button and a "Remove" button. Sub classes can - * overwrite this method if need other functions. - * - * @param parent - * @param toolkit - */ - protected void createOperationSection(Composite parent, FormToolkit toolkit) { - Composite operationContainer = toolkit.createComposite(parent); - GridData gd = new GridData(GridData.FILL_VERTICAL); - operationContainer.setLayoutData(gd); - GridLayout layout = new GridLayout(); - - operationContainer.setLayout(layout); - - Button addButton = toolkit.createButton(operationContainer, - EditorMessages.UI_Button_Add, SWT.PUSH); - gd = new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING); - gd.grabExcessHorizontalSpace = false; - addButton.setLayoutData(gd); - - addButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - addButtonSelected(e); - } - }); - - setRemoveButton(toolkit.createButton(operationContainer, - EditorMessages.UI_Button_Remove, SWT.PUSH)); - - gd = new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING); - gd.grabExcessHorizontalSpace = false; - getRemoveButton().setLayoutData(gd); - getRemoveButton().addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - removeButtonSelected(e); - } - }); - } - - /** - * - * @param e - */ - protected abstract void addButtonSelected(SelectionEvent e); - - /** - * - * @param e - */ - protected void removeButtonSelected(SelectionEvent e) { - - IStructuredSelection ssel = StructuredSelection.EMPTY; - ISelection selection = getSelection(); - if (selection instanceof IStructuredSelection) { - ssel = (IStructuredSelection) selection; - } - - if (!ssel.isEmpty()) { - List commands = new ArrayList(ssel.size()); - for (Iterator iter = ssel.iterator(); iter.hasNext();) { - EObject element = (EObject) iter.next(); - Command command = RemoveCommand.create(getEditingDomain(), - element); - commands.add(command); - } - - CompoundCommand command = new CompoundCommand(commands); - if (command.canExecute()) { - getEditingDomain().getCommandStack().execute(command); - } - } - - } - - /** - * - * update the buttons' enable state. - */ - protected void updateButtons() { - IStructuredSelection ssel = (IStructuredSelection) structuredViewer - .getSelection(); - - getRemoveButton().setEnabled(!ssel.isEmpty()); - } - - /** - * - */ - public ISelection getSelection() { - return structuredViewer.getSelection(); - } - - /** - * - */ - public void setSelection(ISelection selection) { - structuredViewer.setSelection(selection); - } - - /** - * refresh the display of this section. - */ - public void refresh() { - super.refresh(); - structuredViewer.refresh(); - updateButtons(); - } - - /** - * - */ - public void refreshAll() { - // master section refresh all: - setViewerInput(getInput()); - updateButtons(); - - // detial sections refresh: - // fire an event to the detail sections, let them - // refresh. - selectionChanged(null); - } - - /** - * set the structuredViewer's input - * - * @param input - */ - private void setViewerInput(Object input) { - structuredViewer.setInput(input); - } - - /** - * - */ - protected void expansionStateChanged(boolean expanded) { - if (expanded) { - if (structuredViewer.getInput() == null) { - refreshAll(); - } - structuredViewer.refresh(true); - structuredViewer.setSelection(structuredViewer.getSelection()); - } else { - structuredViewer.setSelection(null); - } - super.expansionStateChanged(expanded); - } - - /** - * - */ - protected void expansionStateChanging(boolean expanding) { - if (!expanding) { - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - this.getSection().setLayoutData(gd); - } else { - ((FacesConfigMasterDetailPage) getPage()).closeOtherSections(this); - - GridData gd = new GridData(GridData.FILL_BOTH); - this.getSection().setLayoutData(gd); - } - - super.expansionStateChanging(expanding); - } - - /** - * get the viewer. - * - * @return the viewer - */ - public StructuredViewer getStructuredViewer() { - return structuredViewer; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.facesconfig.ui.section.AbstractFacesConfigSection#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) - */ - public void selectionChanged(SelectionChangedEvent event) { - super.selectionChanged(event); - updateButtons(); - } - - private void setRemoveButton(Button removeButton) { - this.removeButton = removeButton; - } - - /** - * @return the remove button - */ - protected Button getRemoveButton() { - return removeButton; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/FacetSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/FacetSection.java deleted file mode 100644 index 7bcb10a35..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/FacetSection.java +++ /dev/null @@ -1,451 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.section; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.common.command.CompoundCommand; -import org.eclipse.emf.edit.command.AddCommand; -import org.eclipse.emf.edit.command.RemoveCommand; -import org.eclipse.emf.edit.command.SetCommand; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jst.jsf.facesconfig.emf.DescriptionType; -import org.eclipse.jst.jsf.facesconfig.emf.DisplayNameType; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.emf.FacetNameType; -import org.eclipse.jst.jsf.facesconfig.emf.FacetType; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.jst.jsf.facesconfig.ui.dialog.AddEditFacetDialog; -import org.eclipse.jst.jsf.facesconfig.ui.page.IFacesConfigPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.MouseAdapter; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.widgets.FormToolkit; - -public class FacetSection extends AbstractFacesConfigSection { - - private static final int TABLE_DEFAULT_HEIGHT = 160; - - private TableViewer tableViewer; - - private Button removeButton; - - private Button editButton; - - /** - * - * @param parent - * @param managedForm - * @param page - * @param toolkit - */ - public FacetSection(Composite parent, IManagedForm managedForm, - IFacesConfigPage page, FormToolkit toolkit) { - super(parent, managedForm, page, toolkit, null, null); - this.getSection().setText(EditorMessages.FacetSection_Name); - this.getSection().setDescription( - EditorMessages.FacetSection_Description); - - } - - /** - * - */ - protected void createContents(Composite container, FormToolkit toolkit) { - GridLayout gl = new GridLayout(); - gl.horizontalSpacing = 0; - gl.marginWidth = 0; - gl.numColumns = 2; - container.setLayout(gl); - GridData td = new GridData(GridData.FILL_BOTH); - container.setLayoutData(td); - - toolkit.paintBordersFor(container); - - Composite facetSection = toolkit.createComposite(container); - GridLayout gl2 = new GridLayout(); - gl2.horizontalSpacing = 0; - gl2.marginWidth = 0; - gl2.numColumns = 2; - facetSection.setLayout(gl2); - GridData gd = new GridData(GridData.FILL_BOTH - | GridData.VERTICAL_ALIGN_BEGINNING); - facetSection.setLayoutData(gd); - - createTableSection(facetSection, toolkit); - createButtonsSection(facetSection, toolkit); - - } - - /** - * create facet table section - * - * @param container - * @param toolkit - */ - private void createTableSection(Composite container, FormToolkit toolkit) { - Composite tableContainer = toolkit.createComposite(container); - GridData gd = new GridData(GridData.FILL_BOTH - | GridData.GRAB_HORIZONTAL); - tableContainer.setLayoutData(gd); - toolkit.paintBordersFor(tableContainer); - - GridLayout gl = new GridLayout(); - tableContainer.setLayout(gl); - - Table table = new Table(tableContainer, SWT.H_SCROLL | SWT.V_SCROLL - | SWT.FULL_SELECTION | SWT.BORDER); - gd = new GridData(GridData.FILL_BOTH); - gd.horizontalSpan = 1; - gd.heightHint = TABLE_DEFAULT_HEIGHT; - table.setLayoutData(gd); - - table.setHeaderVisible(true); - table.setLinesVisible(true); - TableLayout layout = new TableLayout(); - table.setLayout(layout); - - TableColumn facetNameCol = new TableColumn(table, SWT.NONE); - layout.addColumnData(new ColumnWeightData(1, true)); - facetNameCol - .setText(EditorMessages.FacetSection_Table_FacetNameColumn); - TableColumn displayNameCol = new TableColumn(table, SWT.NONE); - layout.addColumnData(new ColumnWeightData(1, true)); - displayNameCol - .setText(EditorMessages.FacetSection_Table_DisplayNameColumn);//$NON-NLS-1$ - - TableColumn descriptionCol = new TableColumn(table, SWT.NONE); - layout.addColumnData(new ColumnWeightData(1, true)); - descriptionCol - .setText(EditorMessages.FacetSection_Table_DescriptionColumn); - - table.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - updateButtons(); - } - }); - - table.addMouseListener(new MouseAdapter() { - public void mouseDoubleClick(MouseEvent e) { - if (((IStructuredSelection) tableViewer.getSelection()).size() > 0) - editButtonSelected(); - } - }); - - tableViewer = new TableViewer(table); - tableViewer.setContentProvider(new AdapterFactoryContentProvider( - getAdapterFactory())); - tableViewer.setLabelProvider(new AdapterFactoryLabelProvider( - getAdapterFactory())); - - tableViewer.addFilter(new ViewerFilter() { - public boolean select(Viewer viewer, Object parentElement, - Object element) { - return FacesConfigPackage.eINSTANCE.getFacetType().isInstance( - element); - } - }); - - tableViewer.addSelectionChangedListener(this); - } - - /** - * create buttons - * - * @param container - * @param toolkit - */ - private void createButtonsSection(Composite container, FormToolkit toolkit) { - // create operation buttons's container - Composite operationContainer = toolkit.createComposite(container); - GridData gd = new GridData(GridData.FILL_VERTICAL - | GridData.VERTICAL_ALIGN_BEGINNING); - operationContainer.setLayoutData(gd); - GridLayout gl = new GridLayout(); - operationContainer.setLayout(gl); - - Button addButton = toolkit.createButton(operationContainer, - EditorMessages.UI_Button_Add_more, //$NON-NLS-1$ - SWT.PUSH); - gd = new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING); - gd.grabExcessHorizontalSpace = false; - addButton.setLayoutData(gd); - - editButton = toolkit.createButton(operationContainer, - EditorMessages.UI_Button_Edit_more, //$NON-NLS-1$ - SWT.PUSH); - gd = new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING); - gd.grabExcessHorizontalSpace = false; - editButton.setLayoutData(gd); - - removeButton = toolkit.createButton(operationContainer, - EditorMessages.UI_Button_Remove, //$NON-NLS-1$ - SWT.PUSH); - gd = new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING); - gd.grabExcessHorizontalSpace = false; - removeButton.setLayoutData(gd); - - addButton.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent e) { - addButtonSelected(); - } - }); - - editButton.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent e) { - editButtonSelected(); - } - }); - removeButton.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent e) { - removeButtonSelected(); - } - }); - } - - /** - * refresh the table viewer and update buttons. - */ - public void refresh() { - super.refresh(); - tableViewer.refresh(); - updateButtons(); - } - - public void refreshAll() { - tableViewer.setInput(getInput()); - updateButtons(); - } - - /** - * Update the buttons' enable status. - */ - private void updateButtons() { - if (((IStructuredSelection) tableViewer.getSelection()).size() > 0) { - editButton.setEnabled(true); - removeButton.setEnabled(true); - } else { - editButton.setEnabled(false); - removeButton.setEnabled(false); - } - } - - /** - * add a facet. - * - */ - private void addButtonSelected() { - - Shell shell = EditorPlugin.getActiveShell(); - - AddEditFacetDialog dialog = new AddEditFacetDialog(shell, true); - if (dialog.open() == Dialog.OK) { - - String newFacetName = dialog.getFacetName(); - String newDisplayName = dialog.getDisplayName(); - String newDescription = dialog.getDescription(); - - FacetType newFacet = FacesConfigFactory.eINSTANCE.createFacetType(); - if (newFacetName.length() > 0) { - FacetNameType facetNameType = FacesConfigFactory.eINSTANCE - .createFacetNameType(); - facetNameType.setTextContent(newFacetName); - newFacet.setFacetName(facetNameType); - } - - if (newDisplayName.length() > 0) { - DisplayNameType displayNameType = FacesConfigFactory.eINSTANCE - .createDisplayNameType(); - displayNameType.setTextContent(newDisplayName); - newFacet.getDisplayName().add(displayNameType); - } - - if (newDescription.length() > 0) { - DescriptionType descriptionType = FacesConfigFactory.eINSTANCE - .createDescriptionType(); - descriptionType.setTextContent(newDescription); - newFacet.getDescription().add(descriptionType); - } - - Command addCommand = AddCommand.create(this.getEditingDomain(), - getInput(), FacesConfigPackage.eINSTANCE - .getComponentType_Facet(), newFacet); - if (addCommand.canExecute()) { - this.getEditingDomain().getCommandStack().execute(addCommand); - - } - } - - } - - /** - * edit a facet. - * - */ - private void editButtonSelected() { - FacetType facet = (FacetType) ((IStructuredSelection) tableViewer - .getSelection()).getFirstElement(); - - Assert.isNotNull(facet); - - Shell shell = EditorPlugin.getActiveShell(); - - AddEditFacetDialog dialog = new AddEditFacetDialog(shell, false); - if (facet.getFacetName() != null) - dialog.setFacetName(facet.getFacetName().getTextContent()); - - if (facet.getDisplayName().size() > 0) { - dialog.setDisplayName(((DisplayNameType) facet.getDisplayName() - .get(0)).getTextContent()); - } - - if (facet.getDescription().size() > 0) { - dialog.setDescription(((DescriptionType) facet.getDescription() - .get(0)).getTextContent()); - } - - if (dialog.open() == Dialog.OK) { - List commands = new ArrayList(3); - - String newFacetName = dialog.getFacetName(); - String newDisplayName = dialog.getDisplayName(); - String newDescription = dialog.getDescription(); - if (facet.getFacetName() != null) { - Command cmd1 = SetCommand.create(getEditingDomain(), facet - .getFacetName(), FacesConfigPackage.eINSTANCE - .getFacetNameType_TextContent(), newFacetName); - commands.add(cmd1); - } else if (newFacetName.length() > 0) { - FacetNameType newFacetNameType = FacesConfigFactory.eINSTANCE - .createFacetNameType(); - newFacetNameType.setTextContent(newFacetName); - Command cmd2 = AddCommand.create(getEditingDomain(), facet, - FacesConfigPackage.eINSTANCE.getFacetType_FacetName(), - newFacetNameType); - commands.add(cmd2); - } - - if (facet.getDisplayName().size() > 0) { - DisplayNameType displayNameType = (DisplayNameType) facet - .getDisplayName().get(0); - Command cmd3 = SetCommand.create(this.getEditingDomain(), - displayNameType, FacesConfigPackage.eINSTANCE - .getDisplayNameType_TextContent(), - newDisplayName); - commands.add(cmd3); - } else if (newDisplayName.length() > 0) { - DisplayNameType newDisplayNameType = FacesConfigFactory.eINSTANCE - .createDisplayNameType(); - newDisplayNameType.setTextContent(newDisplayName); - Command cmd4 = AddCommand - .create(this.getEditingDomain(), facet, - FacesConfigPackage.eINSTANCE - .getFacetType_DisplayName(), - newDisplayNameType); - commands.add(cmd4); - } - - if (facet.getDescription().size() > 0) { - DescriptionType descriptionType = (DescriptionType) facet - .getDescription().get(0); - Command cmd5 = SetCommand.create(this.getEditingDomain(), - descriptionType, FacesConfigPackage.eINSTANCE - .getDescriptionType_TextContent(), - newDescription); - commands.add(cmd5); - } else if (newDescription.length() > 0) { - DescriptionType newDescriptionType = FacesConfigFactory.eINSTANCE - .createDescriptionType(); - newDescriptionType.setTextContent(newDescription); - Command cmd6 = AddCommand - .create(this.getEditingDomain(), facet, - FacesConfigPackage.eINSTANCE - .getFacetType_Description(), - newDescriptionType); - commands.add(cmd6); - } - - CompoundCommand command = new CompoundCommand(commands); - if (command.canExecute()) { - getEditingDomain().getCommandStack().execute(command); - tableViewer.refresh(facet); - } - } - - } - - /** - * remove a facet. - * - */ - private void removeButtonSelected() { - FacetType facet = (FacetType) ((IStructuredSelection) tableViewer - .getSelection()).getFirstElement(); - - Assert.isNotNull(facet); - Command removeCommand = RemoveCommand.create(this.getEditingDomain(), - getInput(), FacesConfigPackage.eINSTANCE - .getComponentType_Facet(), facet); - - if (removeCommand.canExecute()) { - this.getEditingDomain().getCommandStack().execute(removeCommand); - refreshAll(); - } - - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection() - */ - public ISelection getSelection() { - return tableViewer.getSelection(); - } - - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection) - */ - public void setSelection(ISelection selection) { - - tableViewer.setSelection(selection); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/FactorySection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/FactorySection.java deleted file mode 100644 index 2ffe62a07..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/FactorySection.java +++ /dev/null @@ -1,169 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.section; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.common.command.CompoundCommand; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.edit.command.AddCommand; -import org.eclipse.jdt.ui.IJavaElementSearchConstants; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory; -import org.eclipse.jst.jsf.facesconfig.emf.FactoryType; -import org.eclipse.jst.jsf.facesconfig.ui.dialog.DialogUtil; -import org.eclipse.jst.jsf.facesconfig.ui.page.IFacesConfigPage; -import org.eclipse.jst.jsf.facesconfig.ui.page.OthersPage; -import org.eclipse.jst.jsf.facesconfig.ui.util.ModelUtil; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * @author Zhi-peng Zhang, sfshi - * @version - */ -public class FactorySection extends OthersPageBaseSection { - /** The Eclass object this Section operated */ - private EClass factoryChildClass; - - /** - * - * @param factoryChildClass - * @param parent - * @param managedForm - * @param page - * @param toolkit - * @param helpContextId - * @param helpTooltip - */ - public FactorySection(EClass factoryChildClass, Composite parent, - IManagedForm managedForm, IFacesConfigPage page, - FormToolkit toolkit, String helpContextId, String helpTooltip) { - super(parent, managedForm, page, toolkit, helpContextId, helpTooltip); - this.factoryChildClass = factoryChildClass; - } - - /** - * - * @param factoryChildClass - * @param parent - * @param managedForm - * @param page - * @param toolkit - */ - public FactorySection(EClass factoryChildClass, Composite parent, - IManagedForm managedForm, IFacesConfigPage page, FormToolkit toolkit) { - this(factoryChildClass, parent, managedForm, page, toolkit, null, null); - } - - /** - * @return an new object which is instance of <code>factoryChildClass</code>. - */ - public EObject createFactoryChildObject() { - String superType = ModelUtil.getSuperType(factoryChildClass); - IProject project = (IProject) this.getPage().getEditor().getAdapter( - IProject.class); - String result = DialogUtil.openClassDialog(getSection().getShell(), - project, superType, - IJavaElementSearchConstants.CONSIDER_ALL_TYPES); - - if (result != null) { - EObject component = FacesConfigFactory.eINSTANCE - .create(factoryChildClass); - // set the text content value. - EStructuralFeature feature = factoryChildClass - .getEStructuralFeatures().get(0); - component.eSet(feature, result); - return component; - } - return null; - } - - /** - * Set the <factory> element as the structuredViewer's input. - * - * @param input - */ - protected void setViewerInput(Object input) { - if (input instanceof FactoryType) { - tableViewer.setInput(input); - } else - tableViewer.setInput(null); - } - - /** - * Add a filter on the table viewer. Only the elements that is a instance of - * <code>factoryChildClass</code> could be selected. - */ - protected void configTableViewer(TableViewer tableViewer1) { - tableViewer1.addFilter(new ViewerFilter() { - public boolean select(Viewer viewer, Object parentElement, - Object element) { - return factoryChildClass.isInstance(element); - } - }); - } - - /** - * Perform some actions to create new child object and append it to the - * <factory> element. - */ - void addButtonSelected(SelectionEvent e) { - /** Create a new object which is instance of factoryChildClass. */ - EObject obj = createFactoryChildObject(); - if (obj != null) { - boolean needRefreshAll = false; - Command command = null; - if (getInput() instanceof FactoryType) { - /** - * The input is a <factory> element and not null, append the new - * object to it. - */ - FactoryType factory = (FactoryType) getInput(); - command = AddCommand.create(getEditingDomain(), factory, null, - obj); - } else { - /** - * The input is null, create a <factory> element and append it - * to <faces-config>. - */ - needRefreshAll = true; - List list = new ArrayList(2); - FactoryType factory = FacesConfigFactory.eINSTANCE - .createFactoryType(); - Command cmd1 = AddCommand.create(getEditingDomain(), factory, - null, obj); - list.add(cmd1); - Command cmd2 = AddCommand.create(getEditingDomain(), this - .getPage().getInput(), null, factory); - list.add(cmd2); - command = new CompoundCommand(list); - } - - if (command.canExecute()) { - getEditingDomain().getCommandStack().execute(command); - if (needRefreshAll) - ((OthersPage) this.getPage()).resetFactoryInput(); - } - } - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/IDialogFieldGroup.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/IDialogFieldGroup.java deleted file mode 100644 index 5c5b7c544..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/IDialogFieldGroup.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.section; - -/** - * This interface is used to build relation between model SSEModel and - * controller DialogFieldGroup - * - * @author Xiao-guang Zhang - * @version - */ -public interface IDialogFieldGroup { - /** - * set the input of this section - * - * @param newInput - */ - void setInput(Object newInput); - - /** - * @return the input of this section - */ - Object getInput(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/IFacesConfigSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/IFacesConfigSection.java deleted file mode 100644 index 4fb65dcd2..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/IFacesConfigSection.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.section; - - -/** - * Section interface to build relation between model and adapter - * - * @author sfshi - * - */ -public interface IFacesConfigSection { - /** - * set the input of this section - * - * @param newInput - */ - void setInput(Object newInput); - - /** - * @return the input of this section - */ - Object getInput(); - - /** - * initialize current section based on the input - * - */ - void initialize(); - - /** - * clear all section's contents. - * - */ - void clearAll(); - - /** - * refresh the needed parts of the section - * - */ - void refresh(); - - /** - * refresh all parts of the section - * - */ - void refreshAll(); - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/InitializationSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/InitializationSection.java deleted file mode 100644 index db1dcb425..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/InitializationSection.java +++ /dev/null @@ -1,363 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.section; - -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.edit.command.SetCommand; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.IDialogFieldApplyListener; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.RadiosDialogField; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanType; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.IFacesConfigConstants; -import org.eclipse.jst.jsf.facesconfig.ui.page.IFacesConfigPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.part.PageBook; - -/** - * This section handles managed bean's initialization, including general class - * type, map and list type managed bean. - * - * @author Xiao-guang Zhang, sfshi - */ -public class InitializationSection extends AbstractFacesConfigSection { - private static final String MANAGEDBEAN_GENERAL_CLASS = EditorMessages.InitializationSection_ClassType_General; - - private static final String MANAGEDBEAN_MAP = EditorMessages.InitializationSection_ClassType_Map; - - private static final String MANAGEDBEAN_LIST = EditorMessages.InitializationSection_ClassType_List; - - /** property initiliazation container composite */ - private Composite propertySection; - - /** property initiliazation DialogFieldGroup */ - private ManagedPropertyEditGroup managedPropertyGroup; - - /** map entries initiliazation container composite */ - private Composite mapSection; - - /** map entries initiliazation DialogFieldGroup */ - private MapEntriesEditGroup mapEntryGroup; - - /** list entries initiliazation container composite */ - private Composite listSection; - - /** list entries initiliazation DialogFieldGroup */ - private ListEntriesEditGroup listEntryGroup; - - /** the PageBook control for three kinds of managed bean */ - private PageBook pageBook; - - /** RadiosDialogField for three kinds of managed bean */ - private RadiosDialogField beanTypeField; - - /** current pages selection */ - private int currentPageIndex = 0; - - /** - * @param parent - * @param managedForm - * @param page - * @param toolkit - */ - public InitializationSection(Composite parent, IManagedForm managedForm, - IFacesConfigPage page, FormToolkit toolkit) { - super(parent, managedForm, page, toolkit, null, null); //$NON-NLS-1$ - getSection().setText(EditorMessages.InitializationSection_Name); //$NON-NLS-1$ - getSection().setDescription( - EditorMessages.InitializationSection_Description); //$NON-NLS-1$ - - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.managedbean.sections.BaseSectionPart#createClient(org.eclipse.swt.widgets.Composite, - * org.eclipse.ui.forms.widgets.FormToolkit) - */ - protected void createContents(Composite container, FormToolkit toolkit) { - int numberOfColumns = 3; - GridLayout gl = new GridLayout(numberOfColumns, false); - gl.horizontalSpacing = 0; - gl.marginWidth = 0; - container.setLayout(gl); - toolkit.paintBordersFor(container); - - createBeanTypeEntry(container, toolkit, numberOfColumns); - createInitializationEntry(container, toolkit, numberOfColumns); - } - - /** - * create the bean type selection section - * - * @param container - * @param toolkit - */ - private void createBeanTypeEntry(Composite container, FormToolkit toolkit, - int numberOfColumns) { - beanTypeField = new RadiosDialogField(); - String[] items = { MANAGEDBEAN_GENERAL_CLASS, MANAGEDBEAN_MAP, - MANAGEDBEAN_LIST }; - beanTypeField - .setLabelText(EditorMessages.InitializationSection_ClassType); - beanTypeField.setItems(items); - beanTypeField.doFillIntoGrid(toolkit, container, numberOfColumns); - beanTypeField - .setDialogFieldApplyListener(new IDialogFieldApplyListener() { - public void dialogFieldApplied(DialogField field) { - RadiosDialogField beanTypeField1 = (RadiosDialogField) field; - - boolean bChangedSuccess = false; - if (beanTypeField1.getSelectedIndex() == 0) { - bChangedSuccess = switchPage( - IFacesConfigConstants.MANAGED_PROPERTY, - false); - } else if (beanTypeField1.getSelectedIndex() == 1) { - bChangedSuccess = switchPage( - IFacesConfigConstants.MAP_ENTRIES, false); - } else if (beanTypeField1.getSelectedIndex() == 2) { - bChangedSuccess = switchPage( - IFacesConfigConstants.LIST_ENTRIES, false); - } - - if (bChangedSuccess) { - currentPageIndex = beanTypeField1.getSelectedIndex(); - } else { - beanTypeField1.setSelectedIndexWithoutUpdate(-1); - beanTypeField1 - .setSelectedIndexWithoutUpdate(currentPageIndex); - } - } - }); - } - - /** - * switch to general property, map-entries, or list-entries group If - * bForceClear equals to true, the others page will be cleared without user - * confirmation. if bForceClear equals to false, the confirmation dialog - * will pop up and let user determine whether this page is cleared or not. - * - * @param pageID - - * IFacesConfigConstants.MANAGED_PROPERTY, - * MAP_ENTRIES,LIST_ENTRIES - * @param bForceClearOthers - - * Force to clear other pages. - */ - private boolean switchPage(String pageID, boolean bForceClearOthers) { - if (pageID == IFacesConfigConstants.MANAGED_PROPERTY) { - if (clearPage(IFacesConfigConstants.MAP_ENTRIES, bForceClearOthers) - && clearPage(IFacesConfigConstants.LIST_ENTRIES, - bForceClearOthers)) { - managedPropertyGroup.refreshAll(); - pageBook.showPage(propertySection); - // FIXME: there should be some other methods to resize the whole - // section. - InitializationSection.this.getSection().setExpanded(false); - InitializationSection.this.getSection().setExpanded(true); - return true; - } - } else if (pageID == IFacesConfigConstants.MAP_ENTRIES) { - if (clearPage(IFacesConfigConstants.MANAGED_PROPERTY, - bForceClearOthers) - && clearPage(IFacesConfigConstants.LIST_ENTRIES, - bForceClearOthers)) { - mapEntryGroup.refreshAll(); - pageBook.showPage(mapSection); - // FIXME: there should be some other methods to resize the whole - // section. - InitializationSection.this.getSection().setExpanded(false); - InitializationSection.this.getSection().setExpanded(true); - return true; - } - } else if (pageID == IFacesConfigConstants.LIST_ENTRIES) { - if (clearPage(IFacesConfigConstants.MANAGED_PROPERTY, - bForceClearOthers) - && clearPage(IFacesConfigConstants.MAP_ENTRIES, - bForceClearOthers)) { - listEntryGroup.refreshAll(); - pageBook.showPage(listSection); - // FIXME: there should be some other methods to resize the whole - // section. - InitializationSection.this.getSection().setExpanded(false); - InitializationSection.this.getSection().setExpanded(true); - return true; - } - } - return false; - } - - /** - * clear one specified page according to pageID if bForceClear equals to - * false, the confirmation dialog will pop up and let user determine whether - * this page is cleared or not. - * - * @param pageID - - * IFacesConfigConstants.MANAGED_PROPERTY, - * MAP_ENTRIES,LIST_ENTRIES - * @param bForceClear - - * force to clear current page. - * @return - */ - private boolean clearPage(String pageID, boolean bForceClear) { - ManagedBeanType managedBean = (ManagedBeanType) getInput(); - - if (pageID == IFacesConfigConstants.MANAGED_PROPERTY) { - if (managedBean.getManagedProperty().size() == 0) { - return true; - } - - if (bForceClear - || EditorPlugin - .getAlerts() - .confirm( - "ManagedBeanInitializationSection.Remove.Title", - "ManagedBeanInitializationSection.RemoveManagedProperty")) { - Command cmd = SetCommand.create(this.getEditingDomain(), - managedBean, FacesConfigPackage.eINSTANCE - .getManagedBeanType_ManagedProperty(), - SetCommand.UNSET_VALUE); - if (cmd.canExecute()) { - getEditingDomain().getCommandStack().execute(cmd); - return true; - } - - return false; - } - } else if (pageID == IFacesConfigConstants.MAP_ENTRIES) { - if (managedBean.getMapEntries() == null) { - return true; - } - - if (bForceClear - || EditorPlugin - .getAlerts() - .confirm( - "ManagedBeanInitializationSection.Remove.Title", - "ManagedBeanInitializationSection.RemoveMapEntries")) { - Command cmd = SetCommand.create(this.getEditingDomain(), - managedBean, FacesConfigPackage.eINSTANCE - .getManagedBeanType_MapEntries(), - SetCommand.UNSET_VALUE); - if (cmd.canExecute()) { - getEditingDomain().getCommandStack().execute(cmd); - return true; - } - } - } else if (pageID == IFacesConfigConstants.LIST_ENTRIES) { - if (managedBean.getListEntries() == null) { - return true; - } - - if (bForceClear - || EditorPlugin - .getAlerts() - .confirm( - "ManagedBeanInitializationSection.Remove.Title", - "ManagedBeanInitializationSection.RemoveListEntries")) { - Command cmd = SetCommand.create(this.getEditingDomain(), - managedBean, FacesConfigPackage.eINSTANCE - .getManagedBeanType_ListEntries(), - SetCommand.UNSET_VALUE); - if (cmd.canExecute()) { - getEditingDomain().getCommandStack().execute(cmd); - return true; - } - } - } - - return false; - } - - /** - * create property initialization section - * - * @param container - * @param toolkit - */ - private void createInitializationEntry(Composite container, - FormToolkit toolkit, int numberOfColumns) { - pageBook = new PageBook(container, SWT.NONE); - GridData gd = new GridData(GridData.FILL_BOTH); - gd.horizontalSpan = numberOfColumns; - pageBook.setLayoutData(gd); - toolkit.paintBordersFor(pageBook); - - managedPropertyGroup = new ManagedPropertyEditGroup(this); - managedPropertyGroup.initialize(); - managedPropertyGroup.addSelectionChangedListener(this); - - mapEntryGroup = new MapEntriesEditGroup(this); - mapEntryGroup.initialize(); - mapEntryGroup.addSelectionChangedListener(this); - - listEntryGroup = new ListEntriesEditGroup(this); - listEntryGroup.initialize(); - listEntryGroup.addSelectionChangedListener(this); - - propertySection = toolkit.createComposite(pageBook); - GridLayout gl = new GridLayout(); - gl.horizontalSpacing = 0; - gl.marginWidth = 0; - propertySection.setLayout(gl); - gd = new GridData(GridData.FILL_BOTH); - propertySection.setLayoutData(gd); - managedPropertyGroup.layoutDialogFields(toolkit, propertySection); - - mapSection = toolkit.createComposite(pageBook); - mapEntryGroup.layoutDialogFields(toolkit, mapSection); - - listSection = toolkit.createComposite(pageBook); - listEntryGroup.layoutDialogFields(toolkit, listSection); - - pageBook.showPage(propertySection); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.managedbean.sections.ISSESection#setInput(java.lang.Object) - */ - public void setInput(Object newInput) { - super.setInput(newInput); - refreshAll(); - } - - public void refreshAll() { - if (getInput() instanceof ManagedBeanType) { - ManagedBeanType managedBean = (ManagedBeanType) getInput(); - managedPropertyGroup.setInput(managedBean); - mapEntryGroup.setInput(managedBean); - listEntryGroup.setInput(managedBean); - if (managedBean.getManagedProperty().size() > 0) { - beanTypeField.setSelectedIndexWithoutUpdate(-1); - beanTypeField.setSelectedIndex(0); - } else if (managedBean.getMapEntries() != null) { - beanTypeField.setSelectedIndexWithoutUpdate(-1); - beanTypeField.setSelectedIndex(1); - } else if (managedBean.getListEntries() != null) { - beanTypeField.setSelectedIndexWithoutUpdate(-1); - beanTypeField.setSelectedIndex(2); - } else { - beanTypeField.setSelectedIndexWithoutUpdate(-1); - beanTypeField.setSelectedIndex(0); - } - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/LifecycleSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/LifecycleSection.java deleted file mode 100644 index 2c694c7d1..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/LifecycleSection.java +++ /dev/null @@ -1,156 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.section; - -import org.eclipse.core.resources.IProject; -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.edit.command.AddCommand; -import org.eclipse.jdt.ui.IJavaElementSearchConstants; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory; -import org.eclipse.jst.jsf.facesconfig.emf.LifecycleType; -import org.eclipse.jst.jsf.facesconfig.ui.dialog.DialogUtil; -import org.eclipse.jst.jsf.facesconfig.ui.page.IFacesConfigPage; -import org.eclipse.jst.jsf.facesconfig.ui.page.OthersPage; -import org.eclipse.jst.jsf.facesconfig.ui.util.ModelUtil; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * @author Zhi-peng Zhang - * @version - */ -public class LifecycleSection extends OthersPageBaseSection { - - /** - * The Eclass object this Section operated. Since lifecycle only has one - * type child: phase-listener, so this object should always equals - * <code>FacesConfigPackage.eINSTANCE - .getPhaseListenerType()</code>. - */ - private EClass lifecycleChildClass; - - /** - * - * @param lifecycleChildClass - * @param parent - * @param managedForm - * @param page - * @param toolkit - * @param helpContextId - * @param helpTooltip - */ - public LifecycleSection(EClass lifecycleChildClass, Composite parent, - IManagedForm managedForm, IFacesConfigPage page, - FormToolkit toolkit, String helpContextId, String helpTooltip) { - super(parent, managedForm, page, toolkit, helpContextId, helpTooltip); - this.lifecycleChildClass = lifecycleChildClass; - } - - /** - * - * @param lifecycleChildClass - * @param parent - * @param managedForm - * @param page - * @param toolkit - */ - public LifecycleSection(EClass lifecycleChildClass, Composite parent, - IManagedForm managedForm, IFacesConfigPage page, FormToolkit toolkit) { - this(lifecycleChildClass, parent, managedForm, page, toolkit, null, - null); - } - - public EObject createLifecycleChildObject() { - String superType = ModelUtil.getSuperType(lifecycleChildClass); - IProject project = (IProject) this.getPage().getEditor().getAdapter( - IProject.class); - String result = DialogUtil.openClassDialog(getSection().getShell(), - project, superType, - IJavaElementSearchConstants.CONSIDER_ALL_TYPES); - - if (result != null) { - EObject component = FacesConfigFactory.eINSTANCE - .create(lifecycleChildClass); - EStructuralFeature feature = lifecycleChildClass - .getEStructuralFeatures().get(0); - component.eSet(feature, result); - return component; - } - return null; - } - - /** - * Set the <lifecycle> element as the structuredViewer's input. - * - * @param input - */ - protected void setViewerInput(Object input) { - if (input instanceof LifecycleType) { - tableViewer.setInput(input); - } else - tableViewer.setInput(null); - } - - /** - * Add a filter on the table viewer. Only the elements that is a instance of - * <code>lifecycleChildClass</code> could be selected. - */ - protected void configTableViewer(TableViewer tableViewer1) { - tableViewer1.addFilter(new ViewerFilter() { - public boolean select(Viewer viewer, Object parentElement, - Object element) { - return lifecycleChildClass.isInstance(element); - } - }); - } - - /** - * Perform some actions to create new child object and append it to the - * <lifecycle> element. - */ - void addButtonSelected(SelectionEvent e) { - EObject obj = createLifecycleChildObject(); - if (obj != null) { - - boolean needRefreshAll = false; - Command command = null; - if (getInput() instanceof LifecycleType) { - LifecycleType lifeCycle = (LifecycleType) getInput(); - command = AddCommand.create(getEditingDomain(), lifeCycle, - null, obj); - } else { - needRefreshAll = true; - LifecycleType lifeCycle = FacesConfigFactory.eINSTANCE - .createLifecycleType(); - lifeCycle.getPhaseListener().add(obj); - command = AddCommand.create(getEditingDomain(), this.getPage() - .getInput(), null, lifeCycle); - } - - if (command.canExecute()) { - getEditingDomain().getCommandStack().execute(command); - if (needRefreshAll) - ((OthersPage) this.getPage()).resetLifecycleInput(); - } - } - - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ListEntriesEditGroup.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ListEntriesEditGroup.java deleted file mode 100644 index 1f623822a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ListEntriesEditGroup.java +++ /dev/null @@ -1,630 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.section; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.common.command.CompoundCommand; -import org.eclipse.emf.edit.command.AddCommand; -import org.eclipse.emf.edit.command.RemoveCommand; -import org.eclipse.emf.edit.command.SetCommand; -import org.eclipse.emf.edit.domain.EditingDomain; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.ClassButtonDialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogFieldBase; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogFieldGroup; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.IDialogFieldApplyListener; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.LayoutUtil; -import org.eclipse.jst.jsf.common.ui.internal.guiutils.SWTUtils; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.emf.ListEntriesType; -import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanType; -import org.eclipse.jst.jsf.facesconfig.emf.NullValueType; -import org.eclipse.jst.jsf.facesconfig.emf.ValueClassType; -import org.eclipse.jst.jsf.facesconfig.emf.ValueType; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.dialog.EditValueDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.MouseAdapter; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * ListEntries editing DialogFieldGroup - * - * @author Xiao-guang Zhang, sfshi - * @version - */ -public class ListEntriesEditGroup extends DialogFieldGroup implements - IDialogFieldGroup, ISelectionProvider, ISelectionChangedListener { - - private ClassButtonDialogField valueClassField; - - private static final int TABLE_DEFAULT_HEIGHT = 160; - - private IProject currentProject; - - private TableViewer tableViewer; - - private Button removeButton; - - private Button editButton; - - private ManagedBeanType managedBean; - - private AbstractFacesConfigSection section; - - private List selectionChangedListeners = new ArrayList(); - - /** - * @param section - */ - public ListEntriesEditGroup(AbstractFacesConfigSection section) { - super(); - this.section = section; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogFieldGroup#initialize() - */ - public void initialize() { - // TODO: initialize? - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogFieldGroup#refreshData() - */ - public void refreshData() { - // TODO: initialize? - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogFieldGroup#layoutDialogFields(org.eclipse.ui.forms.widgets.FormToolkit, - * org.eclipse.swt.widgets.Composite) - */ - public void layoutDialogFields(FormToolkit toolkit, Composite parent) { - GridData data = new GridData(GridData.FILL_BOTH); - parent.setLayoutData(data); - - GridLayout gl = new GridLayout(); - gl.verticalSpacing = 0; - gl.marginHeight = 0; - parent.setLayout(gl); - - layoutListTypeSelectionSection(toolkit, parent); - - createAndLayoutListValueSection(toolkit, parent); - } - - /** - * - */ - private void layoutListTypeSelectionSection(FormToolkit toolkit, - Composite container) { - Composite typeSelectionSection = null; - if (toolkit != null) { - typeSelectionSection = toolkit.createComposite(container); - toolkit.paintBordersFor(typeSelectionSection); - } else { - typeSelectionSection = SWTUtils - .createComposite(container, SWT.NONE); - } - - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - typeSelectionSection.setLayoutData(gd); - - int numberOfColumns = 4; - GridLayout gl = new GridLayout(numberOfColumns, false); - typeSelectionSection.setLayout(gl); - valueClassField = new ClassButtonDialogField(getProject()); - - valueClassField - .setLabelText(EditorMessages.InitializationSection_MapType_ValueClass);//$NON-NLS-1$ - valueClassField - .setDialogFieldApplyListener(new IDialogFieldApplyListener() { - - public void dialogFieldApplied(DialogField field) { - ManagedBeanType managedBean_ = (ManagedBeanType) getInput(); - String className = ((ClassButtonDialogField) field) - .getText(); - ValueClassType valueClass = FacesConfigFactory.eINSTANCE - .createValueClassType(); - valueClass.setTextContent(className); - EditingDomain editingDomain = section - .getEditingDomain(); - Command cmd; - boolean isNew; - if (managedBean_.getListEntries() == null) { - isNew = true; - ListEntriesType listEntries = FacesConfigFactory.eINSTANCE - .createListEntriesType(); - listEntries.setValueClass(valueClass); - cmd = SetCommand.create(editingDomain, managedBean_, - FacesConfigPackage.eINSTANCE - .getManagedBeanType_ListEntries(), - listEntries); - } else { - isNew = false; - ListEntriesType listEntries = managedBean_ - .getListEntries(); - cmd = SetCommand.create(editingDomain, listEntries, - FacesConfigPackage.eINSTANCE - .getListEntriesType_ValueClass(), - valueClass); - } - - if (cmd.canExecute()) { - editingDomain.getCommandStack().execute(cmd); - if (isNew) - refreshAll(); - } - - } - }); - valueClassField.doFillIntoGrid(toolkit, typeSelectionSection, - numberOfColumns); - LayoutUtil.setHorizontalGrabbing(valueClassField.getTextControl( - toolkit, container)); - } - - /** - * @param toolkit - * @param parent - */ - private void createAndLayoutListValueSection(FormToolkit toolkit, - Composite parent) { - Composite listValueSection = null; - if (toolkit != null) { - listValueSection = toolkit.createComposite(parent); - toolkit.paintBordersFor(listValueSection); - } else { - listValueSection = SWTUtils.createComposite(parent, SWT.NONE); - } - - GridData gd = new GridData(GridData.FILL_BOTH); - listValueSection.setLayoutData(gd); - - int numberOfColumns = 3; - GridLayout gl = new GridLayout(numberOfColumns, false); - listValueSection.setLayout(gl); - DialogFieldBase valuesTitle = new DialogFieldBase(); - valuesTitle - .setLabelText(EditorMessages.InitializationSection_MapTable_Title);//$NON-NLS-1$ - valuesTitle.doFillIntoGrid(toolkit, listValueSection, numberOfColumns); - - // list's value table - Table listTable; - if (toolkit == null) { - listTable = new Table(listValueSection, SWT.H_SCROLL | SWT.V_SCROLL - | SWT.FULL_SELECTION | SWT.BORDER); - } else { - listTable = new Table(listValueSection, SWT.H_SCROLL | SWT.V_SCROLL - | SWT.FULL_SELECTION | SWT.BORDER); - } - - listTable.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - updateButtons(); - } - - public void widgetDefaultSelected(SelectionEvent e) { - updateButtons(); - } - - }); - gd = new GridData(GridData.FILL_BOTH); - gd.horizontalSpan = 1; - gd.heightHint = TABLE_DEFAULT_HEIGHT; - listTable.setLayoutData(gd); - listTable.setHeaderVisible(true); - listTable.setLinesVisible(true); - TableLayout layout = new TableLayout(); - layout.addColumnData(new ColumnWeightData(1, true)); - listTable.setLayout(layout); - TableColumn valueCol = new TableColumn(listTable, SWT.NONE); - layout.addColumnData(new ColumnWeightData(1, true)); - valueCol - .setText(EditorMessages.InitializationSection_MapTable_Value);//$NON-NLS-1$ - valueCol.setResizable(true); - - listTable.addMouseListener(new MouseAdapter() { - public void mouseDoubleClick(MouseEvent e) { - if (((IStructuredSelection) tableViewer.getSelection()).size() > 0) - editButtonSelected(); - } - }); - tableViewer = new TableViewer(listTable); - tableViewer.setContentProvider(new AdapterFactoryContentProvider( - section.getAdapterFactory())); - tableViewer.setLabelProvider(new AdapterFactoryLabelProvider(section - .getAdapterFactory())); - - tableViewer.addFilter(new ViewerFilter() { - public boolean select(Viewer viewer, Object parentElement, - Object element) { - return FacesConfigPackage.eINSTANCE.getValueType().isInstance( - element) - || FacesConfigPackage.eINSTANCE.getNullValueType() - .isInstance(element); - } - }); - tableViewer.addSelectionChangedListener(this); - - Composite operationContainer = null; - if (toolkit != null) { - operationContainer = toolkit.createComposite(listValueSection); - } else { - operationContainer = SWTUtils.createComposite(listValueSection, - SWT.NONE); - } - gd = new GridData(GridData.FILL_VERTICAL); - operationContainer.setLayoutData(gd); - gl = new GridLayout(); - operationContainer.setLayout(gl); - - Button addButton = null; - if (toolkit != null) { - addButton = toolkit.createButton(operationContainer, - EditorMessages.UI_Button_Add_more, //$NON-NLS-1$ - SWT.PUSH); - } else { - addButton = SWTUtils.createPushButton(operationContainer, - EditorMessages.UI_Button_Add_more); //$NON-NLS-1$ - } - gd = new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING); - gd.grabExcessHorizontalSpace = false; - addButton.setLayoutData(gd); - - editButton = null; - if (toolkit != null) { - editButton = toolkit.createButton(operationContainer, - EditorMessages.UI_Button_Edit_more, SWT.PUSH); - } else { - editButton = SWTUtils.createPushButton(operationContainer, - EditorMessages.UI_Button_Edit_more); - } - - gd = new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING); - gd.grabExcessHorizontalSpace = false; - editButton.setLayoutData(gd); - - removeButton = null; - if (toolkit != null) { - removeButton = toolkit.createButton(operationContainer, - EditorMessages.UI_Button_Remove, //$NON-NLS-1$ - SWT.PUSH); - } else { - removeButton = SWTUtils.createPushButton(operationContainer, - EditorMessages.UI_Button_Remove); //$NON-NLS-1$ - } - - gd = new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING); - gd.grabExcessHorizontalSpace = false; - removeButton.setLayoutData(gd); - - addButton.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent e) { - addButtonSelected(); - } - - }); - - editButton.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent e) { - editButtonSelected(); - } - }); - removeButton.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent e) { - removeButtonSelected(); - } - }); - } - - protected void addButtonSelected() { - EditValueDialog dialog = new EditValueDialog(EditorPlugin - .getActiveShell(), true, false, null); - if (dialog.open() == Dialog.OK) { - - EditingDomain editingDomain = section.getEditingDomain(); - if (this.managedBean.getListEntries() == null) { - ListEntriesType listEntries = FacesConfigFactory.eINSTANCE - .createListEntriesType(); - if (dialog.isNullValue()) { - NullValueType nullValue = FacesConfigFactory.eINSTANCE - .createNullValueType(); - listEntries.getNullValue().add(nullValue); - } else { - ValueType value = FacesConfigFactory.eINSTANCE - .createValueType(); - value.setTextContent((String) dialog.getResultData()); - listEntries.getValue().add(value); - } - - Command cmd1 = SetCommand.create(editingDomain, managedBean, - FacesConfigPackage.eINSTANCE - .getManagedBeanType_ListEntries(), listEntries); - if (cmd1.canExecute()) { - editingDomain.getCommandStack().execute(cmd1); - refreshAll(); - } - } else { - ListEntriesType listEntries = managedBean.getListEntries(); - Command cmd; - if (dialog.isNullValue()) { - NullValueType nullValue = FacesConfigFactory.eINSTANCE - .createNullValueType(); - cmd = AddCommand.create(editingDomain, listEntries, - FacesConfigPackage.eINSTANCE - .getListEntriesType_NullValue(), nullValue); - } else { - ValueType value = FacesConfigFactory.eINSTANCE - .createValueType(); - value.setTextContent((String) dialog.getResultData()); - cmd = AddCommand.create(editingDomain, listEntries, - FacesConfigPackage.eINSTANCE - .getListEntriesType_Value(), value); - } - if (cmd.canExecute()) { - editingDomain.getCommandStack().execute(cmd); - } - } - - } - } - - protected void editButtonSelected() { - Object select = ((IStructuredSelection) tableViewer.getSelection()) - .getFirstElement(); - boolean isNullValue; - String valueText = null; - if (select instanceof NullValueType) - isNullValue = true; - else { - isNullValue = false; - valueText = ((ValueType) select).getTextContent(); - } - ListEntriesType listEntries = managedBean.getListEntries(); - EditValueDialog dialog = new EditValueDialog(EditorPlugin - .getActiveShell(), true, isNullValue, valueText); - if (dialog.open() == Dialog.OK) { - EditingDomain editingDomain = section.getEditingDomain(); - Command cmd = null; - if (isNullValue && !dialog.isNullValue()) { - List commands = new ArrayList(); - Command cmd1 = RemoveCommand.create(editingDomain, listEntries, - FacesConfigPackage.eINSTANCE - .getListEntriesType_NullValue(), select); - commands.add(cmd1); - - // listEntries.getNullValue().remove(select); - ValueType value = FacesConfigFactory.eINSTANCE - .createValueType(); - value.setTextContent((String) dialog.getResultData()); - Command cmd2 = AddCommand - .create(editingDomain, listEntries, - FacesConfigPackage.eINSTANCE - .getListEntriesType_Value(), value); - commands.add(cmd2); - cmd = new CompoundCommand(commands); - } else if (!isNullValue && dialog.isNullValue()) { - List commands = new ArrayList(); - Command cmd1 = RemoveCommand - .create(editingDomain, listEntries, - FacesConfigPackage.eINSTANCE - .getListEntriesType_Value(), select); - commands.add(cmd1); - NullValueType nullValue = FacesConfigFactory.eINSTANCE - .createNullValueType(); - Command cmd2 = AddCommand.create(editingDomain, listEntries, - FacesConfigPackage.eINSTANCE - .getListEntriesType_NullValue(), nullValue); - commands.add(cmd2); - cmd = new CompoundCommand(commands); - } else if (!isNullValue && !dialog.isNullValue()) { - cmd = SetCommand - .create(editingDomain, select, - FacesConfigPackage.eINSTANCE - .getValueType_TextContent(), dialog - .getResultData()); - } - - if (cmd != null && cmd.canExecute()) { - editingDomain.getCommandStack().execute(cmd); - } - } - } - - protected void removeButtonSelected() { - Object select = ((IStructuredSelection) tableViewer.getSelection()) - .getFirstElement(); - ListEntriesType listEntries = managedBean.getListEntries(); - EditingDomain editingDomain = section.getEditingDomain(); - Command cmd; - if (select instanceof NullValueType) { - cmd = RemoveCommand - .create(editingDomain, listEntries, - FacesConfigPackage.eINSTANCE - .getListEntriesType_NullValue(), select); - } else { - cmd = RemoveCommand.create(editingDomain, listEntries, - FacesConfigPackage.eINSTANCE.getListEntriesType_Value(), - select); - } - if (cmd.canExecute()) { - editingDomain.getCommandStack().execute(cmd); - } - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.managedbean.sections.wizards.IDialogFieldGroup#setInput(java.lang.Object) - */ - public void setInput(Object newInput) { - if (newInput != null && newInput instanceof ManagedBeanType) { - managedBean = (ManagedBeanType) newInput; - if (managedBean.getListEntries() != null) - refreshAll(); - } - - } - - /** - * - */ - public void refreshAll() { - if (managedBean.getListEntries() != null - && managedBean.getListEntries().getValueClass() != null) { - this.valueClassField.setTextWithoutUpdate(managedBean - .getListEntries().getValueClass().getTextContent()); - } else { - valueClassField.setTextWithoutUpdate(null); - } - tableViewer.setInput(((ManagedBeanType) getInput()).getListEntries()); - updateButtons(); - } - - /* - * (non-Javadoc) - * - * @see com.sybase.stf.jmt.editors.pageflow.managedbean.sections.wizards.IDialogFieldGroup#getInput() - */ - public Object getInput() { - return managedBean; - } - - private IProject getProject() { - if (currentProject == null) { - currentProject = (IProject) section.getPage().getEditor() - .getAdapter(IProject.class); - } - return currentProject; - } - - public void setProject(IProject project) { - currentProject = project; - } - - public void updateButtons() { - if (((IStructuredSelection) tableViewer.getSelection()).size() > 0) { - editButton.setEnabled(true); - removeButton.setEnabled(true); - } else { - editButton.setEnabled(false); - removeButton.setEnabled(false); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogFieldGroup#validateDialogFields() - */ - public IStatus[] validateDialogFields() { - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ISelectionProvider#addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) - */ - public void addSelectionChangedListener(ISelectionChangedListener listener) { - selectionChangedListeners.add(listener); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection() - */ - public ISelection getSelection() { - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ISelectionProvider#removeSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) - */ - public void removeSelectionChangedListener( - ISelectionChangedListener listener) { - selectionChangedListeners.remove(listener); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection) - */ - public void setSelection(ISelection selection) { - // do nothing - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) - */ - public void selectionChanged(SelectionChangedEvent event) { - for (Iterator listeners = selectionChangedListeners.iterator(); listeners - .hasNext();) { - ISelectionChangedListener listener = (ISelectionChangedListener) listeners - .next(); - listener.selectionChanged(new SelectionChangedEvent(this, event - .getSelection())); - } - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/LocaleConfigSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/LocaleConfigSection.java deleted file mode 100644 index 518364884..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/LocaleConfigSection.java +++ /dev/null @@ -1,380 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.section; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.common.command.CompoundCommand; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.impl.AdapterImpl; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.emf.edit.command.AddCommand; -import org.eclipse.emf.edit.command.RemoveCommand; -import org.eclipse.emf.edit.command.SetCommand; -import org.eclipse.jface.viewers.CheckStateChangedEvent; -import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.viewers.ICheckStateListener; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jface.viewers.ViewerSorter; -import org.eclipse.jst.jsf.facesconfig.emf.ApplicationType; -import org.eclipse.jst.jsf.facesconfig.emf.DefaultLocaleType; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.emf.LocaleConfigType; -import org.eclipse.jst.jsf.facesconfig.emf.SupportedLocaleType; -import org.eclipse.jst.jsf.facesconfig.ui.dialog.DialogUtil; -import org.eclipse.jst.jsf.facesconfig.ui.page.IFacesConfigPage; -import org.eclipse.jst.jsf.facesconfig.ui.page.OthersPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * @author Zhi-peng Zhang, sfshi - * @version - */ -public class LocaleConfigSection extends ApplicationSection implements - ICheckStateListener { - /** - * - * @param componentClass - * @param parent - * @param managedForm - * @param page - * @param toolkit - * @param helpContextId - * @param helpTooltip - */ - public LocaleConfigSection(EClass componentClass, Composite parent, - IManagedForm managedForm, IFacesConfigPage page, - FormToolkit toolkit, String helpContextId, String helpTooltip) { - super(componentClass, parent, managedForm, page, toolkit, - helpContextId, helpTooltip); - } - - /** - * - * @param componentClass - * @param parent - * @param managedForm - * @param page - * @param toolkit - */ - public LocaleConfigSection(EClass componentClass, Composite parent, - IManagedForm managedForm, IFacesConfigPage page, FormToolkit toolkit) { - this(componentClass, parent, managedForm, page, toolkit, null, null); - } - - /** - * create a CheckboxTableViewer for this section. - */ - protected TableViewer createTableViewer(Composite parent) { - CheckboxTableViewer tableViewer1 = CheckboxTableViewer.newCheckList( - parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); - tableViewer1.addCheckStateListener(this); - tableViewer1.setSorter(new ViewerSorter()); - return tableViewer1; - } - - /** - * Add a filter for this table viewer, only <supported-locale> and - * <default-locale> elements would be listed. - */ - protected void configTableViewer(TableViewer tableViewer1) { - tableViewer1.addFilter(new ViewerFilter() { - public boolean select(Viewer viewer, Object parentElement, - Object element) { - return FacesConfigPackage.eINSTANCE.getSupportedLocaleType() - .isInstance(element) - || FacesConfigPackage.eINSTANCE.getDefaultLocaleType() - .isInstance(element); - } - }); - } - - /** - * Pop up a dialog for user to select a locale string, then create a - * <supported-locale> element with the string as value. - * - * @return the supported locale object - */ - public SupportedLocaleType createSupportedLocaleObject() { - ArrayList locales = new ArrayList(); - - /** - * Compute the locales that already declared in this <locale-config> - * element. If user select a locale that already declared, then a - * warning message will be shown in the dialog. - */ - - if (getInput() instanceof ApplicationType - && ((ApplicationType) getInput()).getLocaleConfig().size() > 0) { - LocaleConfigType localeConfigType = (LocaleConfigType) ((ApplicationType) getInput()) - .getLocaleConfig().get(0); - if (localeConfigType.getDefaultLocale() != null) { - String locale = localeConfigType.getDefaultLocale() - .getTextContent(); - if (locale != null) { - locales.add(locale); - } - } - List list = localeConfigType.getSupportedLocale(); - for (int i = 0, n = list.size(); i < n; i++) { - String locale = ((SupportedLocaleType) list.get(i)) - .getTextContent(); - if (locale != null) { - locales.add(locale); - } - } - } - String result = DialogUtil.openLocaleDialog(getSection().getShell(), - locales); - if (result != null) { - SupportedLocaleType component = FacesConfigFactory.eINSTANCE - .createSupportedLocaleType(); - component.setTextContent(result); - return component; - } - return null; - } - - /** - * When user click "Add" button on this section, pop up a dialog to create a - * <supported-locale> element, then add it onto <locale-config> element, if - * the <locale-config> or <application> doesn't exist, create them together. - */ - void addButtonSelected(SelectionEvent e) { - SupportedLocaleType obj = createSupportedLocaleObject(); - if (obj != null) { - - boolean needRefreshAll = false; - Command command = null; - - if (getInput() instanceof ApplicationType) { - /** the <application> element exists. */ - ApplicationType application = (ApplicationType) getInput(); - if (application.getLocaleConfig().size() > 0) { - /** the <locale-config> element exists. */ - LocaleConfigType localeConfig = (LocaleConfigType) application - .getLocaleConfig().get(0); - command = AddCommand.create(this.getEditingDomain(), - localeConfig, null, obj); - } else { - /** the <locale-config> element doesn't exist, create it. */ - LocaleConfigType localeConfig = FacesConfigFactory.eINSTANCE - .createLocaleConfigType(); - localeConfig.getSupportedLocale().add(obj); - command = AddCommand.create(getEditingDomain(), - application, null, localeConfig); - } - } else { - /** - * the <application> element doesn't exist, then create it, - * after execute, reset the input for all the application - * sections. - */ - needRefreshAll = true; - ApplicationType application = FacesConfigFactory.eINSTANCE - .createApplicationType(); - LocaleConfigType localeConfig = FacesConfigFactory.eINSTANCE - .createLocaleConfigType(); - localeConfig.getSupportedLocale().add(obj); - application.getLocaleConfig().add(localeConfig); - command = AddCommand.create(getEditingDomain(), this.getPage() - .getInput(), null, application); - } - - if (command.canExecute()) { - getEditingDomain().getCommandStack().execute(command); - if (needRefreshAll) - /** reset input for all the application sections. */ - ((OthersPage) this.getPage()).resetApplicationInput(); - } - } - - } - - /** - * when user click on the CheckboxTableViewer, perform some actions to - * set/unset <default-locale> and <supported-locale> elements. - * - * If an item is selected, that means it's a <default-locale>, otherwise - * it's a <supported-locale>. - * - * @see org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged(org.eclipse.jface.viewers.CheckStateChangedEvent) - */ - public void checkStateChanged(CheckStateChangedEvent event) { - boolean checked = event.getChecked(); - - if (event.getElement() == null) { - return; - } - - EObject node = (EObject) event.getElement(); - LocaleConfigType localeConfigType = (LocaleConfigType) ((ApplicationType) getInput()) - .getLocaleConfig().get(0); - CompoundCommand compoundCommand = new CompoundCommand(); - - if (checked) { - /** user checked one item, going to set it as <default-locale>. */ - if (localeConfigType.getDefaultLocale() != null) { - /** - * Change the <default-locale> value to <supported-locale>. - */ - Command command = RemoveCommand.create(getEditingDomain(), - localeConfigType, null, localeConfigType - .getDefaultLocale()); - - compoundCommand.append(command); - - SupportedLocaleType supportedLocale = FacesConfigFactory.eINSTANCE - .createSupportedLocaleType(); - supportedLocale.setTextContent(localeConfigType - .getDefaultLocale().getTextContent()); - command = AddCommand.create(getEditingDomain(), - localeConfigType, FacesConfigPackage.eINSTANCE - .getLocaleConfigType_SupportedLocale(), - supportedLocale); - compoundCommand.append(command); - } - - /** - * Change the selected item from <supported-locale> to - * <default-locale> - */ - SupportedLocaleType supportedLocale = (SupportedLocaleType) node; - Command command = RemoveCommand.create(getEditingDomain(), - localeConfigType, FacesConfigPackage.eINSTANCE - .getLocaleConfigType_SupportedLocale(), - supportedLocale); - compoundCommand.append(command); - - DefaultLocaleType defaultLocale = FacesConfigFactory.eINSTANCE - .createDefaultLocaleType(); - defaultLocale.setTextContent(supportedLocale.getTextContent()); - command = SetCommand - .create(getEditingDomain(), localeConfigType, - FacesConfigPackage.eINSTANCE - .getLocaleConfigType_DefaultLocale(), - defaultLocale); - compoundCommand.append(command); - - } else { - /** - * User unchecked one item, going to change it from <default-locale> - * to <supported-locale>. - */ - DefaultLocaleType defaultLocale = (DefaultLocaleType) node; - Command command = RemoveCommand.create(getEditingDomain(), - localeConfigType, null, defaultLocale); - compoundCommand.append(command); - - SupportedLocaleType supportedLocale = FacesConfigFactory.eINSTANCE - .createSupportedLocaleType(); - supportedLocale.setTextContent(defaultLocale.getTextContent()); - command = AddCommand.create(getEditingDomain(), localeConfigType, - null, supportedLocale); - compoundCommand.append(command); - } - - if (compoundCommand.canExecute()) { - getEditingDomain().getCommandStack().execute(compoundCommand); - this.refresh(); - setTableViewerCheckedState(); - } - } - - /** - * Set the checked state for items in the checkbox table viewer. This method - * could be used for refresh the checked state of the table viewer. - */ - private void setTableViewerCheckedState() { - if (getInput() instanceof ApplicationType) { - ApplicationType application = (ApplicationType) getInput(); - if (application.getLocaleConfig().size() > 0) { - - LocaleConfigType localeConfigType = (LocaleConfigType) application - .getLocaleConfig().get(0); - if (localeConfigType.getDefaultLocale() != null) { - ((CheckboxTableViewer) getTableViewer()).setChecked( - localeConfigType.getDefaultLocale(), true); - } - } - } - } - - /** - * set the structuredViewer's input. Set the first LocaleConfig as input. - * - * @param input - */ - protected void setViewerInput(Object input) { - if (input instanceof ApplicationType) { - ApplicationType application = (ApplicationType) input; - if (EcoreUtil.getExistingAdapter(application, - LocaleConfigSection.class) == null) { - application.eAdapters().add(new LocaleConfigAdapter()); - } - if (application.getLocaleConfig().size() > 0) { - tableViewer.setInput(application.getLocaleConfig().get(0)); - } else - tableViewer.setInput(null); - } else - tableViewer.setInput(null); - - } - - public void refreshAll() { - super.refreshAll(); - setTableViewerCheckedState(); - } - - /** - * A listener that is be adapted on the input <application> element, to - * listen the event that the first <locale-config> being created and - * removed, then reset the input of the tabel viewer. - * - * @author sfshi - * - */ - class LocaleConfigAdapter extends AdapterImpl { - public boolean isAdapterForType(Object type) { - if (type == LocaleConfigSection.class) - return true; - return false; - } - - public void notifyChanged(Notification msg) { - if (msg.getEventType() == Notification.ADD - || msg.getEventType() == Notification.REMOVE) { - if (msg.getFeature() == FacesConfigPackage.eINSTANCE - .getApplicationType_LocaleConfig()) { - /** - * a <locale-config> was created or removed, notify this - * section to reset it's input. - */ - setInput(getInput()); - - } - } - } - - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ManagedBeanGeneralSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ManagedBeanGeneralSection.java deleted file mode 100644 index e7c475b14..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ManagedBeanGeneralSection.java +++ /dev/null @@ -1,318 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.section; - -import org.eclipse.core.resources.IProject; -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.impl.AdapterImpl; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.emf.edit.command.SetCommand; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.ClassButtonDialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.ComboDialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.IDialogFieldApplyListener; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.IDialogFieldChangeListener; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.LayoutUtil; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.StringDialogField; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanClassType; -import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanNameType; -import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanScopeType; -import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanType; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.jst.jsf.facesconfig.ui.IFacesConfigConstants; -import org.eclipse.jst.jsf.facesconfig.ui.page.IFacesConfigPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * - * @author sfshi - * - */ -public class ManagedBeanGeneralSection extends AbstractFacesConfigSection { - - private StringDialogField mbNameField; - - private ClassButtonDialogField mbClassField; - - private ComboDialogField mbScopeField; - - private ManagedBeanGeneralSectionAdapter managedBeanGeneralSectionAdapter; - - /** - * - * @param parent - * @param managedForm - * @param page - * @param toolkit - */ - public ManagedBeanGeneralSection(Composite parent, - IManagedForm managedForm, IFacesConfigPage page, FormToolkit toolkit) { - super(parent, managedForm, page, toolkit, null, null); - getSection().setText( - EditorMessages.ManagedBeanGeneralSection_Name); - getSection().setDescription( - EditorMessages.ManagedBeanGeneralSection_Desc); - } - - protected void createContents(Composite container, FormToolkit toolkit) { - int numberOfColumns = 4; - GridLayout layout = new GridLayout(numberOfColumns, false); - container.setLayout(layout); - - toolkit.paintBordersFor(container); - - createMBNameEntry(container, toolkit, numberOfColumns); - - createMBClassEntry(container, toolkit, numberOfColumns); - - createMBScopeEntry(container, toolkit, numberOfColumns); - - } - - /** - * create managed bean's name editing field - * - * @param container - * @param toolkit - */ - private void createMBNameEntry(Composite container, FormToolkit toolkit, - int numberOfColumns) { - mbNameField = new StringDialogField(); - mbNameField - .setLabelText(EditorMessages.ManagedBeanGeneralSection_ManagedBeanName);//$NON-NLS-1$ - mbNameField.doFillIntoGrid(toolkit, container, numberOfColumns); - LayoutUtil.setHorizontalGrabbing(mbNameField.getTextControl(toolkit, - container)); - mbNameField - .setDialogFieldApplyListener(new IDialogFieldApplyListener() { - public void dialogFieldApplied(DialogField field) { - String mbNameValue = ((StringDialogField) field) - .getText(); - Command cmd = null; - ManagedBeanType managedBean = (ManagedBeanType) getInput(); - // if (managedBean.getManagedBeanName() != null) { - // cmd = SetCommand - // .create( - // getEditingDomain(), - // managedBean.getManagedBeanName(), - // FacesConfigPackage.eINSTANCE - // .getManagedBeanNameType_TextContent(), - // mbNameValue); - // } else { - ManagedBeanNameType newManagedBeanName = FacesConfigFactory.eINSTANCE - .createManagedBeanNameType(); - newManagedBeanName.setTextContent(mbNameValue); - cmd = SetCommand.create(getEditingDomain(), - managedBean, FacesConfigPackage.eINSTANCE - .getManagedBeanType_ManagedBeanName(), - newManagedBeanName); - // } - if (cmd.canExecute()) { - getEditingDomain().getCommandStack().execute(cmd); - } - } - }); - } - - /** - * create managed bean's class field. - * - * @param container - * @param toolkit - */ - private void createMBClassEntry(final Composite container, - final FormToolkit toolkit, int numberOfColumns) { - mbClassField = new ClassButtonDialogField(null); - mbClassField - .setLabelText(EditorMessages.ManagedBeanGeneralSection_ManagedBeanClass);//$NON-NLS-1$ - mbClassField.setProject((IProject) getPage().getEditor().getAdapter( - IProject.class)); - mbClassField.doFillIntoGrid(toolkit, container, numberOfColumns); - LayoutUtil.setHorizontalGrabbing(mbClassField.getTextControl(toolkit, - container)); - - mbClassField - .setDialogFieldApplyListener(new IDialogFieldApplyListener() { - public void dialogFieldApplied(DialogField field) { - String newValue = ((StringDialogField) field).getText(); - Command cmd = null; - ManagedBeanType managedBean = (ManagedBeanType) getInput(); - // if (managedBean.getManagedBeanClass() != null) { - // cmd = SetCommand - // .create( - // getEditingDomain(), - // managedBean.getManagedBeanClass(), - // FacesConfigPackage.eINSTANCE - // .getManagedBeanClassType_TextContent(), - // newValue); - // } else { - ManagedBeanClassType newManagedBeanClass = FacesConfigFactory.eINSTANCE - .createManagedBeanClassType(); - newManagedBeanClass.setTextContent(newValue); - cmd = SetCommand.create(getEditingDomain(), - managedBean, FacesConfigPackage.eINSTANCE - .getManagedBeanType_ManagedBeanClass(), - newManagedBeanClass); - // } - if (cmd.canExecute()) { - getEditingDomain().getCommandStack().execute(cmd); - } - } - }); - } - - /** - * create managed bean's scope field - * - * @param container - * @param toolkit - */ - private void createMBScopeEntry(Composite container, FormToolkit toolkit, - int numberOfColumns) { - mbScopeField = new ComboDialogField(SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER); - mbScopeField - .setLabelText(EditorMessages.ManagedBeanGeneralSection_ManagedBeanScope);//$NON-NLS-1$ - mbScopeField.doFillIntoGrid(toolkit, container, numberOfColumns); - LayoutUtil.setHorizontalGrabbing(mbScopeField.getComboControl(toolkit, - container)); - - mbScopeField.setItems(ManagedBeanScopeTreeItem.scopeItems); - - mbScopeField - .setDialogFieldChangeListener(new IDialogFieldChangeListener() { - public void dialogFieldChanged(DialogField field) { - String newValue = ((ComboDialogField) field).getText(); - Command cmd = null; - ManagedBeanType managedBean = (ManagedBeanType) getInput(); - // if (managedBean.getManagedBeanScope() != null) { - // cmd = SetCommand - // .create( - // getEditingDomain(), - // managedBean.getManagedBeanScope(), - // FacesConfigPackage.eINSTANCE - // .getManagedBeanScopeType_TextContent(), - // newValue); - // } else { - ManagedBeanScopeType newManagedBeanScope = FacesConfigFactory.eINSTANCE - .createManagedBeanScopeType(); - newManagedBeanScope.setTextContent(newValue); - cmd = SetCommand.create(getEditingDomain(), - managedBean, FacesConfigPackage.eINSTANCE - .getManagedBeanType_ManagedBeanScope(), - newManagedBeanScope); - // } - if (cmd.canExecute()) { - getEditingDomain().getCommandStack().execute(cmd); - } - } - }); - } - - public void refreshAll() { - refresh(); - } - - /** - * - */ - public void refresh() { - super.refresh(); - Object input = this.getInput(); - if (input instanceof ManagedBeanType) { - ManagedBeanType component = (ManagedBeanType) input; - - if (component.getManagedBeanName() != null) { - mbNameField.setTextWithoutUpdate(component.getManagedBeanName() - .getTextContent()); - } else { - mbNameField.setTextWithoutUpdate(""); - } - - if (component.getManagedBeanClass() != null) { - mbClassField.setTextWithoutUpdate(component - .getManagedBeanClass().getTextContent()); - } else { - mbClassField.setTextWithoutUpdate(""); - } - - if (component.getManagedBeanScope() != null) { - mbScopeField.setTextWithoutUpdate(component - .getManagedBeanScope().getTextContent()); - } else { - // defaultly set it's scope to "session"; - mbScopeField - .setTextWithoutUpdate(IFacesConfigConstants.MANAGED_BEAN_SCOPE_SESSION); - } - } - } - - protected void addAdaptersOntoInput(Object newInput) { - super.addAdaptersOntoInput(newInput); - ManagedBeanType managedBean = (ManagedBeanType) newInput; - if (EcoreUtil.getExistingAdapter(managedBean, - ManagedBeanGeneralSection.class) == null) { - managedBean.eAdapters().add(getManagedBeanGeneralSectionAdatper()); - } - - } - - protected void removeAdaptersFromInput(Object oldInput) { - super.removeAdaptersFromInput(oldInput); - ManagedBeanType managedBean = (ManagedBeanType) oldInput; - if (EcoreUtil.getExistingAdapter(managedBean, - ManagedBeanGeneralSection.class) != null) { - managedBean.eAdapters().remove( - getManagedBeanGeneralSectionAdatper()); - } - } - - protected ManagedBeanGeneralSectionAdapter getManagedBeanGeneralSectionAdatper() { - if (managedBeanGeneralSectionAdapter == null) { - managedBeanGeneralSectionAdapter = new ManagedBeanGeneralSectionAdapter(); - } - return managedBeanGeneralSectionAdapter; - } - - class ManagedBeanGeneralSectionAdapter extends AdapterImpl { - - public boolean isAdapterForType(Object type) { - - if (type == ManagedBeanGeneralSection.class) - return true; - return false; - } - - public void notifyChanged(Notification msg) { - if (msg.getEventType() == Notification.ADD - || msg.getEventType() == Notification.REMOVE - || msg.getEventType() == Notification.SET) { - if (msg.getFeature() == FacesConfigPackage.eINSTANCE - .getManagedBeanType_ManagedBeanName() - || msg.getFeature() == FacesConfigPackage.eINSTANCE - .getManagedBeanType_ManagedBeanClass() - || msg.getFeature() == FacesConfigPackage.eINSTANCE - .getManagedBeanType_ManagedBeanScope()) { - refresh(); - } - } - } - - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ManagedBeanMasterSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ManagedBeanMasterSection.java deleted file mode 100644 index 1204dd19d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ManagedBeanMasterSection.java +++ /dev/null @@ -1,354 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.section; - -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.impl.AdapterImpl; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.emf.edit.command.AddCommand; -import org.eclipse.emf.edit.command.RemoveCommand; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.window.Window; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.jst.jsf.facesconfig.emf.DescriptionType; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigType; -import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanClassType; -import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanNameType; -import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanScopeType; -import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanType; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.page.FacesConfigMasterDetailPage; -import org.eclipse.jst.jsf.facesconfig.ui.provider.ManagedBeanContentProvider; -import org.eclipse.jst.jsf.facesconfig.ui.provider.ManagedBeanLabelProvider; -import org.eclipse.jst.jsf.facesconfig.ui.wizard.NewManagedBeanWizard; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * @author sfshi - */ -public class ManagedBeanMasterSection extends FacesConfigMasterSection { - - private ManagedBeanMasterSectionAdapter managedBeanMasterSectionAdapter; - - /** - * @param parent - * @param managedForm - * @param toolkit - * @param page - */ - public ManagedBeanMasterSection(Composite parent, IManagedForm managedForm, - FormToolkit toolkit, FacesConfigMasterDetailPage page) { - super(parent, managedForm, toolkit, page, null, null); - getSection().setText(EditorMessages.ManagedBeanMasterSection_Name); //$NON-NLS-1$ - getSection().setDescription( - EditorMessages.ManagedBeanMasterSection_Description); - } - - protected StructuredViewer createViewer(Composite parent, - FormToolkit toolkit) { - Composite treeContainer = toolkit.createComposite(parent); - toolkit.paintBordersFor(treeContainer); - - GridData gd = new GridData(GridData.FILL_BOTH); - treeContainer.setLayoutData(gd); - GridLayout layout = new GridLayout(); - treeContainer.setLayout(layout); - - // Create tree viewer - TreeViewer treeViewer = new TreeViewer(treeContainer, SWT.SINGLE - | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); - gd = new GridData(GridData.FILL_BOTH); - treeViewer.getControl().setLayoutData(gd); - - treeViewer.setContentProvider(new ManagedBeanContentProvider()); - treeViewer.setLabelProvider(new ManagedBeanLabelProvider()); - treeViewer.addSelectionChangedListener(this); - - treeViewer.setAutoExpandLevel(3); - return treeViewer; - } - - protected void addButtonSelected(SelectionEvent e) { - IProject project = (IProject) this.getPage().getEditor().getAdapter( - IProject.class); - - NewManagedBeanWizard wizard = new NewManagedBeanWizard(project); - IStructuredSelection selection = (IStructuredSelection) this - .getSelection(); - if (selection.getFirstElement() instanceof ManagedBeanScopeTreeItem) { - // if user is selecting a scope tree item, then use this scope as - // the default scope for the new managed bean. - ManagedBeanScopeTreeItem scopeTreeItem = (ManagedBeanScopeTreeItem) selection - .getFirstElement(); - wizard.setDefaultScope(scopeTreeItem.getScope()); - } - - wizard.setForcePreviousAndNextButtons(true); - - Shell shell = EditorPlugin.getActiveShell(); - WizardDialog wizardDialog = new WizardDialog(shell, wizard); - wizardDialog.create(); - wizardDialog.setBlockOnOpen(true); - if (wizardDialog.open() == Window.OK) { - ManagedBeanType managedBean = FacesConfigFactory.eINSTANCE - .createManagedBeanType(); - - ManagedBeanNameType name = FacesConfigFactory.eINSTANCE - .createManagedBeanNameType(); - name.setTextContent(wizard.getManagedBeanName()); - managedBean.setManagedBeanName(name); - - ManagedBeanClassType clazz = FacesConfigFactory.eINSTANCE - .createManagedBeanClassType(); - clazz.setTextContent(wizard.getManagedBeanClass()); - managedBean.setManagedBeanClass(clazz); - - ManagedBeanScopeType scope = FacesConfigFactory.eINSTANCE - .createManagedBeanScopeType(); - scope.setTextContent(wizard.getManagedBeanScope()); - managedBean.setManagedBeanScope(scope); - - String desc = wizard.getManagedBeanDescription(); - if (desc != null && desc.trim().length() > 0) { - DescriptionType description = FacesConfigFactory.eINSTANCE - .createDescriptionType(); - description.setTextContent(wizard.getManagedBeanDescription()); - managedBean.getDescription().add(description); - } - - Command cmd = AddCommand.create(getEditingDomain(), getInput(), - null, managedBean); - if (cmd.canExecute()) { - this.getEditingDomain().getCommandStack().execute(cmd); - } - } - - } - - protected void removeButtonSelected(SelectionEvent e) { - IStructuredSelection ssel = StructuredSelection.EMPTY; - ISelection selection = getSelection(); - if (selection instanceof IStructuredSelection) { - ssel = (IStructuredSelection) selection; - } - - if (!ssel.isEmpty()) { - if (ssel.getFirstElement() instanceof ManagedBeanType) { - ManagedBeanType element = (ManagedBeanType) ssel - .getFirstElement(); - Command command = RemoveCommand.create(getEditingDomain(), this - .getInput(), FacesConfigPackage.eINSTANCE - .getFacesConfigType_ManagedBean(), element); - if (command.canExecute()) { - getEditingDomain().getCommandStack().execute(command); - } - } - } - } - - protected void updateButtons() { - IStructuredSelection ssel = (IStructuredSelection) getStructuredViewer() - .getSelection(); - boolean isRemoveEnable = false; - if (!ssel.isEmpty()) { - Object s1 = ssel.getFirstElement(); - if (s1 instanceof ManagedBeanType) { - isRemoveEnable = true; - } - } - getRemoveButton().setEnabled(isRemoveEnable); - } - - /** - * Override the super method to ignore the selection on ScopeTreeItem. - */ - public void selectionChanged(SelectionChangedEvent event) { - - if (event != null - && event.getSelection() != null - && ((IStructuredSelection) event.getSelection()) - .getFirstElement() instanceof ManagedBeanScopeTreeItem) { - - event = new SelectionChangedEvent(this, StructuredSelection.EMPTY); - } - super.selectionChanged(event); - updateButtons(); - - } - - protected void addAdaptersOntoInput(Object newInput) { - super.addAdaptersOntoInput(newInput); - - FacesConfigType facesConfig = (FacesConfigType) newInput; - if (EcoreUtil.getExistingAdapter(facesConfig, - ManagedBeanMasterSection.class) == null) { - - facesConfig.eAdapters().add(getManagedBeanMasterSectionAdapter()); - } - - List managedbeans = facesConfig.getManagedBean(); - for (Iterator it = managedbeans.iterator(); it.hasNext();) { - ManagedBeanType managedbean = (ManagedBeanType) it.next(); - if (EcoreUtil.getExistingAdapter(managedbean, - ManagedBeanMasterSection.class) == null) { - - managedbean.eAdapters().add( - getManagedBeanMasterSectionAdapter()); - } - } - } - - protected void removeAdaptersFromInput(Object oldInput) { - super.removeAdaptersFromInput(oldInput); - FacesConfigType facesConfig = (FacesConfigType) oldInput; - if (EcoreUtil.getExistingAdapter(facesConfig, - ManagedBeanMasterSection.class) != null) { - - facesConfig.eAdapters() - .remove(getManagedBeanMasterSectionAdapter()); - } - - List managedbeans = facesConfig.getManagedBean(); - for (Iterator it = managedbeans.iterator(); it.hasNext();) { - ManagedBeanType managedbean = (ManagedBeanType) it.next(); - if (EcoreUtil.getExistingAdapter(managedbean, - ManagedBeanMasterSection.class) != null) { - - managedbean.eAdapters().remove( - getManagedBeanMasterSectionAdapter()); - } - } - } - - protected ManagedBeanMasterSectionAdapter getManagedBeanMasterSectionAdapter() { - if (managedBeanMasterSectionAdapter == null) { - managedBeanMasterSectionAdapter = new ManagedBeanMasterSectionAdapter(); - } - return managedBeanMasterSectionAdapter; - } - - class ManagedBeanMasterSectionAdapter extends AdapterImpl { - - public boolean isAdapterForType(Object type) { - if (type == ManagedBeanMasterSection.class) - return true; - return false; - } - - public void notifyChanged(Notification msg) { - super.notifyChanged(msg); - - if (msg.getFeature() == FacesConfigPackage.eINSTANCE - .getFacesConfigType_ManagedBean()) { - if (msg.getEventType() == Notification.ADD) { - final EObject mbean = (EObject) msg.getNewValue(); - if (EcoreUtil.getExistingAdapter(mbean, - ManagedBeanMasterSection.class) == null) { - - mbean.eAdapters().add( - getManagedBeanMasterSectionAdapter()); - } - - Runnable run = new Runnable() { - - public void run() { - getStructuredViewer().refresh(true); - IStructuredSelection selection = new StructuredSelection( - mbean); - getStructuredViewer().setSelection(selection); - } - - }; - PlatformUI.getWorkbench().getDisplay().asyncExec(run); - } else if (msg.getEventType() == Notification.REMOVE) { - - Runnable run = new Runnable() { - public void run() { - getStructuredViewer().refresh(true); - } - - }; - PlatformUI.getWorkbench().getDisplay().asyncExec(run); - } - - else if (msg.getEventType() == Notification.SET) { - final Object mbean = msg.getNewValue(); - Runnable run = new Runnable() { - public void run() { - getStructuredViewer().refresh(mbean, true); - } - - }; - PlatformUI.getWorkbench().getDisplay().asyncExec(run); - } - } - - if (msg.getFeature() == FacesConfigPackage.eINSTANCE - .getManagedBeanType_ManagedBeanClass() - || msg.getFeature() == FacesConfigPackage.eINSTANCE - .getManagedBeanType_ManagedBeanName()) { - - final Object bean = msg.getNotifier(); - - Runnable run = new Runnable() { - - public void run() { - getStructuredViewer().refresh(bean, true); - } - - }; - PlatformUI.getWorkbench().getDisplay().asyncExec(run); - - } else if (msg.getFeature() == FacesConfigPackage.eINSTANCE - .getManagedBeanType_ManagedBeanScope()) { - - final Object mbean = msg.getNotifier(); - - Runnable run1 = new Runnable() { - - public void run() { - getStructuredViewer().refresh(); - IStructuredSelection selection = new StructuredSelection( - mbean); - getStructuredViewer().setSelection(selection); - } - - }; - PlatformUI.getWorkbench().getDisplay().asyncExec(run1); - } - - } - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ManagedBeanScopeTreeItem.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ManagedBeanScopeTreeItem.java deleted file mode 100644 index 69f6016d0..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ManagedBeanScopeTreeItem.java +++ /dev/null @@ -1,79 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.section; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigType; -import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanType; -import org.eclipse.jst.jsf.facesconfig.ui.IFacesConfigConstants; - -/** - * @author Xiao-guang Zhang, sfshi - * @version - */ -public class ManagedBeanScopeTreeItem { - - public static final String[] scopeItems = { - IFacesConfigConstants.MANAGED_BEAN_SCOPE_SESSION, - IFacesConfigConstants.MANAGED_BEAN_SCOPE_REQUEST, - IFacesConfigConstants.MANAGED_BEAN_SCOPE_APPLICATION, - IFacesConfigConstants.MANAGED_BEAN_SCOPE_NONE }; - - private String scope; - - private FacesConfigType facesConfig; - - /** - * - * @param managedBeanScope - * @param facesConfig - */ - public ManagedBeanScopeTreeItem(String managedBeanScope, - FacesConfigType facesConfig) { - super(); - this.scope = managedBeanScope; - - this.facesConfig = facesConfig; - } - - public Object getParent() { - return facesConfig; - } - - public boolean hasChildren() { - return !getChildren().isEmpty(); - } - - public String getScope() { - return scope; - } - - public List getChildren() { - List result = new ArrayList(); - List managedBeans = facesConfig.getManagedBean(); - for (Iterator it = managedBeans.iterator(); it.hasNext();) { - ManagedBeanType managedBean = (ManagedBeanType) it.next(); - - if (managedBean.getManagedBeanScope() != null) { - if (scope.equals(managedBean.getManagedBeanScope() - .getTextContent())) { - result.add(managedBean); - } - } - } - - return result; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ManagedPropertyEditGroup.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ManagedPropertyEditGroup.java deleted file mode 100644 index 18c9fc578..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ManagedPropertyEditGroup.java +++ /dev/null @@ -1,580 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.section; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.common.command.CompoundCommand; -import org.eclipse.emf.edit.command.AddCommand; -import org.eclipse.emf.edit.command.RemoveCommand; -import org.eclipse.emf.edit.command.SetCommand; -import org.eclipse.emf.edit.domain.EditingDomain; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogFieldGroup; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.emf.ListEntriesType; -import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanType; -import org.eclipse.jst.jsf.facesconfig.emf.ManagedPropertyType; -import org.eclipse.jst.jsf.facesconfig.emf.MapEntriesType; -import org.eclipse.jst.jsf.facesconfig.emf.NullValueType; -import org.eclipse.jst.jsf.facesconfig.emf.PropertyClassType; -import org.eclipse.jst.jsf.facesconfig.emf.PropertyNameType; -import org.eclipse.jst.jsf.facesconfig.emf.ValueType; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.IFacesConfigConstants; -import org.eclipse.jst.jsf.facesconfig.ui.dialog.AddEditManagedPropertyDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.MouseAdapter; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * @author sfshi - * @version - */ -public class ManagedPropertyEditGroup extends DialogFieldGroup implements - IDialogFieldGroup, ISelectionProvider, ISelectionChangedListener { - - private TableViewer tableViewer; - - private static final int TABLE_DEFAULT_HEIGHT = 160; - - private Button removeButton; - - private Button editButton; - - private ManagedBeanType managedBean; - - private AbstractFacesConfigSection section; - - private List selectionChangedListeners = new ArrayList(); - - /** - * - */ - public ManagedPropertyEditGroup(AbstractFacesConfigSection section) { - super(); - this.section = section; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogFieldGroup#initialize() - */ - public void initialize() { - // TODO Auto-generated method stub - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogFieldGroup#refreshData() - */ - public void refreshData() { - refresh(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogFieldGroup#layoutDialogFields(org.eclipse.ui.forms.widgets.FormToolkit, - * org.eclipse.swt.widgets.Composite) - */ - public void layoutDialogFields(FormToolkit toolkit, Composite parent) { - createGeneralClassPage(parent, toolkit); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogFieldGroup#validateDialogFields() - */ - public IStatus[] validateDialogFields() { - return null; - } - - /** - * create general class initialization section - * - * @param container - * @param toolkit - */ - private void createGeneralClassPage(Composite container, FormToolkit toolkit) { - Composite generalSection = toolkit.createComposite(container); - generalSection.setLayoutData(new GridData(GridData.FILL_BOTH)); - toolkit.paintBordersFor(generalSection); - - GridLayout gl = new GridLayout(); - gl.horizontalSpacing = 0; - gl.marginWidth = 0; - gl.numColumns = 2; - generalSection.setLayout(gl); - - createTableSection(generalSection, toolkit); - - createButtonsSection(generalSection, toolkit); - } - - /** - * create proeprty table section - * - * @param container - * @param toolkit - */ - private void createTableSection(Composite container, FormToolkit toolkit) { - // create property container - Composite propertyContainer = toolkit.createComposite(container); - GridData gd = new GridData(GridData.FILL_BOTH - | GridData.GRAB_HORIZONTAL); - propertyContainer.setLayoutData(gd); - toolkit.paintBordersFor(propertyContainer); - - GridLayout gl = new GridLayout(); - propertyContainer.setLayout(gl); - - // Create property table - Table table = new Table(propertyContainer, SWT.H_SCROLL | SWT.V_SCROLL - | SWT.FULL_SELECTION | SWT.BORDER); - TableLayout layout = new TableLayout(); - table.setLayout(layout); - gd = new GridData(GridData.FILL_BOTH); - gd.horizontalSpan = 1; - gd.heightHint = TABLE_DEFAULT_HEIGHT; - table.setLayoutData(gd); - - table.setHeaderVisible(true); - table.setLinesVisible(true); - TableColumn propertyCol = new TableColumn(table, SWT.NONE); - layout.addColumnData(new ColumnWeightData(1, true)); - propertyCol - .setText(EditorMessages.InitializationSection_PropertyTable_Name); - propertyCol.setResizable(true); - - TableColumn classCol = new TableColumn(table, SWT.NONE); - layout.addColumnData(new ColumnWeightData(1, true)); - classCol - .setText(EditorMessages.InitializationSection_PropertyTable_Class); - classCol.setResizable(true); - - TableColumn valueCol = new TableColumn(table, SWT.NONE); - layout.addColumnData(new ColumnWeightData(1, true)); - valueCol - .setText(EditorMessages.InitializationSection_PropertyTable_Value); - valueCol.setResizable(true); - - table.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - updateButtons(); - } - }); - - table.addMouseListener(new MouseAdapter() { - public void mouseDoubleClick(MouseEvent e) { - if (((IStructuredSelection) tableViewer.getSelection()).size() > 0) - editButtonSelected(); - } - }); - - tableViewer = new TableViewer(table); - tableViewer.setContentProvider(new AdapterFactoryContentProvider( - section.getAdapterFactory())); - tableViewer.setLabelProvider(new AdapterFactoryLabelProvider(section - .getAdapterFactory())); - - tableViewer.addFilter(new ViewerFilter() { - public boolean select(Viewer viewer, Object parentElement, - Object element) { - return FacesConfigPackage.eINSTANCE.getManagedPropertyType() - .isInstance(element); - } - }); - - tableViewer.addSelectionChangedListener(this); - } - - /** - * Update the buttons' enable and disable status - */ - private void updateButtons() { - if (((IStructuredSelection) tableViewer.getSelection()).size() > 0) { - editButton.setEnabled(true); - removeButton.setEnabled(true); - } else { - editButton.setEnabled(false); - removeButton.setEnabled(false); - } - } - - /** - * create property's editing buttons - * - * @param container - * @param toolkit - */ - private void createButtonsSection(Composite container, FormToolkit toolkit) { - // create operation buttons's container - Composite operationContainer = toolkit.createComposite(container); - GridData gd = new GridData(GridData.FILL_VERTICAL - | GridData.VERTICAL_ALIGN_BEGINNING); - operationContainer.setLayoutData(gd); - GridLayout gl = new GridLayout(); - operationContainer.setLayout(gl); - - // create list operation buttons - Button addButton = toolkit.createButton(operationContainer, - EditorMessages.UI_Button_Add_more, SWT.PUSH); - gd = new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING); - gd.grabExcessHorizontalSpace = false; - addButton.setLayoutData(gd); - - editButton = toolkit.createButton(operationContainer, - EditorMessages.UI_Button_Edit_more, //$NON-NLS-1$ - SWT.PUSH); - gd = new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING); - gd.grabExcessHorizontalSpace = false; - editButton.setLayoutData(gd); - - removeButton = toolkit.createButton(operationContainer, - EditorMessages.UI_Button_Remove, //$NON-NLS-1$ - SWT.PUSH); - gd = new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING); - gd.grabExcessHorizontalSpace = false; - removeButton.setLayoutData(gd); - - addButton.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent e) { - addButtonSelected(); - } - - }); - - editButton.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent e) { - editButtonSelected(); - } - }); - removeButton.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent e) { - removeButtonSelected(); - } - }); - - } - - protected void addButtonSelected() { - Shell shell = EditorPlugin.getActiveShell(); - - AddEditManagedPropertyDialog dialog = new AddEditManagedPropertyDialog( - shell, managedBean, section); - if (dialog.open() == Dialog.OK) { - - ManagedPropertyType managedProperty = createManagedPropertyFromDialog(dialog); - Command addCommand = AddCommand.create(this.getEditingDomain(), - getInput(), FacesConfigPackage.eINSTANCE - .getManagedBeanType_ManagedProperty(), - managedProperty); - if (addCommand.canExecute()) { - this.getEditingDomain().getCommandStack().execute(addCommand); - - } - } - - } - - protected void editButtonSelected() { - ManagedPropertyType managedProperty = (ManagedPropertyType) ((IStructuredSelection) tableViewer - .getSelection()).getFirstElement(); - Shell shell = EditorPlugin.getActiveShell(); - AddEditManagedPropertyDialog dialog = new AddEditManagedPropertyDialog( - shell, managedProperty, section); - if (dialog.open() == Dialog.OK) { - List commands = new ArrayList(); - String propertyName = dialog.getPropertyName(); - String propertyClass = dialog.getPropertyClass(); - PropertyNameType propertyNameType = FacesConfigFactory.eINSTANCE - .createPropertyNameType(); - propertyNameType.setTextContent(propertyName); - Command cmd1 = SetCommand.create(this.getEditingDomain(), - managedProperty, FacesConfigPackage.eINSTANCE - .getManagedPropertyType_PropertyName(), - propertyNameType); - commands.add(cmd1); - - PropertyClassType propertyClassType = FacesConfigFactory.eINSTANCE - .createPropertyClassType(); - propertyClassType.setTextContent(propertyClass); - Command cmd2 = SetCommand.create(this.getEditingDomain(), - managedProperty, FacesConfigPackage.eINSTANCE - .getManagedPropertyType_PropertyClass(), - propertyClassType); - commands.add(cmd2); - - // remove value, null-value, map-entries and list-entries element: - if (managedProperty.getNullValue() != null) { - Command rmCmd = SetCommand.create(this.getEditingDomain(), - managedProperty, FacesConfigPackage.eINSTANCE - .getManagedPropertyType_NullValue(), - SetCommand.UNSET_VALUE); - commands.add(rmCmd); - } - if (managedProperty.getListEntries() != null) { - Command rmCmd = SetCommand.create(this.getEditingDomain(), - managedProperty, FacesConfigPackage.eINSTANCE - .getManagedPropertyType_ListEntries(), - SetCommand.UNSET_VALUE); - commands.add(rmCmd); - } - if (managedProperty.getValue() != null) { - Command rmCmd = SetCommand.create(this.getEditingDomain(), - managedProperty, FacesConfigPackage.eINSTANCE - .getManagedPropertyType_Value(), - SetCommand.UNSET_VALUE); - commands.add(rmCmd); - } - if (managedProperty.getMapEntries() != null) { - Command rmCmd = SetCommand.create(this.getEditingDomain(), - managedProperty, FacesConfigPackage.eINSTANCE - .getManagedPropertyType_MapEntries(), - SetCommand.UNSET_VALUE); - commands.add(rmCmd); - } - - Object valueObject = dialog.getValueObject(); - if (valueObject != null) { - String valueType = dialog.getValueType(); - if (valueType.equals(IFacesConfigConstants.VALUE)) { - - ValueType value = FacesConfigFactory.eINSTANCE - .createValueType(); - value.setTextContent((String) valueObject); - managedProperty.setValue(value); - Command cmd3 = SetCommand.create(this.getEditingDomain(), - managedProperty, FacesConfigPackage.eINSTANCE - .getManagedPropertyType_Value(), value); - commands.add(cmd3); - - } else if (valueType.equals(IFacesConfigConstants.MAP_ENTRIES)) { - - MapEntriesType mapEntriesType = (MapEntriesType) valueObject; - Command cmd3 = SetCommand.create(this.getEditingDomain(), - managedProperty, FacesConfigPackage.eINSTANCE - .getManagedPropertyType_MapEntries(), - mapEntriesType); - commands.add(cmd3); - } else if (valueType.equals(IFacesConfigConstants.LIST_ENTRIES)) { - - ListEntriesType listEntriesType = (ListEntriesType) valueObject; - Command cmd3 = SetCommand.create(this.getEditingDomain(), - managedProperty, FacesConfigPackage.eINSTANCE - .getManagedPropertyType_ListEntries(), - listEntriesType); - commands.add(cmd3); - } else if (valueType.equals(IFacesConfigConstants.NULL_VALUE)) { - - NullValueType nullValue = (NullValueType) valueObject; - Command cmd3 = SetCommand.create(this.getEditingDomain(), - managedProperty, FacesConfigPackage.eINSTANCE - .getManagedPropertyType_NullValue(), - nullValue); - commands.add(cmd3); - } - } - CompoundCommand command = new CompoundCommand(commands); - if (command.canExecute()) { - getEditingDomain().getCommandStack().execute(command); - } - } - } - - protected ManagedPropertyType createManagedPropertyFromDialog( - AddEditManagedPropertyDialog dialog) { - - String propertyName = dialog.getPropertyName(); - String propertyClass = dialog.getPropertyClass(); - - ManagedPropertyType managedProperty = FacesConfigFactory.eINSTANCE - .createManagedPropertyType(); - PropertyNameType propertyNameType = FacesConfigFactory.eINSTANCE - .createPropertyNameType(); - propertyNameType.setTextContent(propertyName); - PropertyClassType propertyClassType = FacesConfigFactory.eINSTANCE - .createPropertyClassType(); - propertyClassType.setTextContent(propertyClass); - managedProperty.setPropertyName(propertyNameType); - managedProperty.setPropertyClass(propertyClassType); - - Object valueObject = dialog.getValueObject(); - if (valueObject != null) { - String valueType = dialog.getValueType(); - if (valueType.equals(IFacesConfigConstants.VALUE)) { - ValueType value = FacesConfigFactory.eINSTANCE - .createValueType(); - value.setTextContent((String) valueObject); - managedProperty.setValue(value); - } else if (valueType.equals(IFacesConfigConstants.MAP_ENTRIES)) { - MapEntriesType mapEntriesType = (MapEntriesType) dialog - .getValueObject(); - managedProperty.setMapEntries(mapEntriesType); - } else if (valueType.equals(IFacesConfigConstants.LIST_ENTRIES)) { - ListEntriesType listEntriesType = (ListEntriesType) dialog - .getValueObject(); - managedProperty.setListEntries(listEntriesType); - } else if (valueType.equals(IFacesConfigConstants.NULL_VALUE)) { - NullValueType nullValue = (NullValueType) dialog - .getValueObject(); - managedProperty.setNullValue(nullValue); - } - } - return managedProperty; - } - - protected void removeButtonSelected() { - ManagedPropertyType managedProperty = (ManagedPropertyType) ((IStructuredSelection) tableViewer - .getSelection()).getFirstElement(); - Assert.isNotNull(managedProperty); - - Command removeCommand = RemoveCommand.create(this.getEditingDomain(), - this.getInput(), FacesConfigPackage.eINSTANCE - .getManagedBeanType_ManagedProperty(), managedProperty); - - if (removeCommand.canExecute()) { - this.getEditingDomain().getCommandStack().execute(removeCommand); - refreshAll(); - } - } - - public void setInput(Object newInput) { - if (newInput != null && newInput instanceof ManagedBeanType) { - managedBean = (ManagedBeanType) newInput; - refreshAll(); - } - } - - /** - * - */ - public void refreshAll() { - tableViewer.setInput(getInput()); - updateButtons(); - - } - - /** - * - */ - public void refresh() { - tableViewer.refresh(); - updateButtons(); - } - - public Object getInput() { - return managedBean; - } - - public EditingDomain getEditingDomain() { - return section.getEditingDomain(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ISelectionProvider#addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) - */ - public void addSelectionChangedListener(ISelectionChangedListener listener) { - // TODO Auto-generated method stub - selectionChangedListeners.add(listener); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection() - */ - public ISelection getSelection() { - // TODO Auto-generated method stub - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ISelectionProvider#removeSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) - */ - public void removeSelectionChangedListener( - ISelectionChangedListener listener) { - // TODO Auto-generated method stub - selectionChangedListeners.remove(listener); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection) - */ - public void setSelection(ISelection selection) { - // TODO Auto-generated method stub - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) - */ - public void selectionChanged(SelectionChangedEvent event) { - // TODO Auto-generated method stub - for (Iterator listeners = selectionChangedListeners.iterator(); listeners - .hasNext();) { - ISelectionChangedListener listener = (ISelectionChangedListener) listeners - .next(); - listener.selectionChanged(new SelectionChangedEvent(this, event - .getSelection())); - } - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/MapEntriesEditGroup.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/MapEntriesEditGroup.java deleted file mode 100644 index a2f16a086..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/MapEntriesEditGroup.java +++ /dev/null @@ -1,695 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.section; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.common.command.CompoundCommand; -import org.eclipse.emf.edit.command.AddCommand; -import org.eclipse.emf.edit.command.RemoveCommand; -import org.eclipse.emf.edit.command.SetCommand; -import org.eclipse.emf.edit.domain.EditingDomain; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.ClassButtonDialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogFieldBase; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogFieldGroup; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.IDialogFieldApplyListener; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.LayoutUtil; -import org.eclipse.jst.jsf.common.ui.internal.guiutils.SWTUtils; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.emf.KeyClassType; -import org.eclipse.jst.jsf.facesconfig.emf.KeyType; -import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanType; -import org.eclipse.jst.jsf.facesconfig.emf.MapEntriesType; -import org.eclipse.jst.jsf.facesconfig.emf.MapEntryType; -import org.eclipse.jst.jsf.facesconfig.emf.NullValueType; -import org.eclipse.jst.jsf.facesconfig.emf.ValueClassType; -import org.eclipse.jst.jsf.facesconfig.emf.ValueType; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.dialog.AddEditMapEntryDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.MouseAdapter; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * MapEntries Editing DialogFieldGroup - * - * @author sfshi - * @version - */ -public class MapEntriesEditGroup extends DialogFieldGroup implements - IDialogFieldGroup, ISelectionProvider, ISelectionChangedListener { - private ClassButtonDialogField keyClassField; - - private ClassButtonDialogField valueClassField; - - private TableViewer tableViewer; - - private static final int TABLE_DEFAULT_HEIGHT = 160; - - private IProject currentProject; - - private Button removeButton; - - private Button editButton; - - private ManagedBeanType managedBean; - - private AbstractFacesConfigSection section; - - private List selectionChangedListeners = new ArrayList(); - - /** - */ - public MapEntriesEditGroup(AbstractFacesConfigSection section) { - super(); - this.section = section; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogFieldGroup#initialize() - */ - public void initialize() { - // TODO: initialize? - } - - public void updateButtons() { - if (((IStructuredSelection) tableViewer.getSelection()).size() > 0) { - editButton.setEnabled(true); - removeButton.setEnabled(true); - } else { - editButton.setEnabled(false); - removeButton.setEnabled(false); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogFieldGroup#layoutDialogFields(org.eclipse.ui.forms.widgets.FormToolkit, - * org.eclipse.swt.widgets.Composite) - */ - public void layoutDialogFields(FormToolkit toolkit, Composite parent) { - GridData data = new GridData(GridData.FILL_BOTH); - parent.setLayoutData(data); - - GridLayout gl = new GridLayout(); - gl.verticalSpacing = 0; - gl.marginHeight = 0; - parent.setLayout(gl); - - layoutMapTypeSelectionSection(toolkit, parent); - - createAndLayoutMapValueSection(toolkit, parent); - } - - /** - * - */ - private void layoutMapTypeSelectionSection(FormToolkit toolkit, - Composite container) { - - Composite typeSelectionSection = null; - if (toolkit != null) { - typeSelectionSection = toolkit.createComposite(container); - toolkit.paintBordersFor(typeSelectionSection); - } else { - typeSelectionSection = SWTUtils - .createComposite(container, SWT.NONE); - } - - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - typeSelectionSection.setLayoutData(gd); - - int numberOfColumns = 4; - GridLayout gl = new GridLayout(numberOfColumns, false); - typeSelectionSection.setLayout(gl); - keyClassField = new ClassButtonDialogField(getProject()); - keyClassField - .setLabelText(EditorMessages.InitializationSection_MapType_KeyClass); - keyClassField - .setDialogFieldApplyListener(new IDialogFieldApplyListener() { - - public void dialogFieldApplied(DialogField field) { - ManagedBeanType managedBean1 = (ManagedBeanType) getInput(); - String className = ((ClassButtonDialogField) field) - .getText(); - KeyClassType keyClass = FacesConfigFactory.eINSTANCE - .createKeyClassType(); - keyClass.setTextContent(className); - EditingDomain editingDomain = section - .getEditingDomain(); - Command cmd; - boolean isNew; - if (managedBean1.getMapEntries() == null) { - isNew = true; - MapEntriesType mapEntries = FacesConfigFactory.eINSTANCE - .createMapEntriesType(); - mapEntries.setKeyClass(keyClass); - cmd = SetCommand.create(editingDomain, managedBean1, - FacesConfigPackage.eINSTANCE - .getManagedBeanType_MapEntries(), - mapEntries); - } else { - isNew = false; - cmd = SetCommand.create(editingDomain, managedBean1 - .getMapEntries(), - FacesConfigPackage.eINSTANCE - .getMapEntriesType_KeyClass(), - keyClass); - } - - if (cmd.canExecute()) { - editingDomain.getCommandStack().execute(cmd); - if (isNew) - refreshAll(); - } - - } - }); - - valueClassField = new ClassButtonDialogField(getProject()); - - valueClassField - .setLabelText(EditorMessages.InitializationSection_MapType_ValueClass); - valueClassField - .setDialogFieldApplyListener(new IDialogFieldApplyListener() { - - public void dialogFieldApplied(DialogField field) { - ManagedBeanType managedBean1 = (ManagedBeanType) getInput(); - String className = ((ClassButtonDialogField) field) - .getText(); - ValueClassType valueClass = FacesConfigFactory.eINSTANCE - .createValueClassType(); - valueClass.setTextContent(className); - EditingDomain editingDomain = section - .getEditingDomain(); - Command cmd; - boolean isNew; - if (managedBean1.getMapEntries() == null) { - isNew = true; - MapEntriesType mapEntries = FacesConfigFactory.eINSTANCE - .createMapEntriesType(); - mapEntries.setValueClass(valueClass); - cmd = SetCommand.create(editingDomain, managedBean1, - FacesConfigPackage.eINSTANCE - .getManagedBeanType_MapEntries(), - mapEntries); - } else { - isNew = false; - cmd = SetCommand.create(editingDomain, managedBean1 - .getMapEntries(), - FacesConfigPackage.eINSTANCE - .getMapEntriesType_ValueClass(), - valueClass); - } - - if (cmd.canExecute()) { - editingDomain.getCommandStack().execute(cmd); - if (isNew) - refreshAll(); - } - - } - }); - - keyClassField.doFillIntoGrid(toolkit, typeSelectionSection, - numberOfColumns); - LayoutUtil.setHorizontalGrabbing(keyClassField.getTextControl(toolkit, - container)); - - valueClassField.doFillIntoGrid(toolkit, typeSelectionSection, - numberOfColumns); - } - - /** - * @param toolkit - * @param parent - */ - private void createAndLayoutMapValueSection(FormToolkit toolkit, - Composite parent) { - Composite mapValueSection = null; - if (toolkit != null) { - mapValueSection = toolkit.createComposite(parent); - toolkit.paintBordersFor(mapValueSection); - } else { - mapValueSection = SWTUtils.createComposite(parent, SWT.NONE); - } - - GridData gd = new GridData(GridData.FILL_BOTH); - mapValueSection.setLayoutData(gd); - - int numberOfColumns = 3; - GridLayout gl = new GridLayout(numberOfColumns, false); - mapValueSection.setLayout(gl); - DialogField valuesTitle = new DialogFieldBase(); - valuesTitle - .setLabelText(EditorMessages.InitializationSection_MapTable_Title);//$NON-NLS-1$ - - valuesTitle.doFillIntoGrid(toolkit, mapValueSection, numberOfColumns); - Table table; - if (toolkit == null) { - table = new Table(mapValueSection, SWT.FULL_SELECTION - | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); - } else { - table = new Table(mapValueSection, SWT.H_SCROLL | SWT.V_SCROLL - | SWT.FULL_SELECTION | SWT.BORDER); - } - - table.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent e) { - updateButtons(); - - } - }); - gd = new GridData(GridData.FILL_BOTH); - gd.horizontalSpan = 1; - gd.heightHint = TABLE_DEFAULT_HEIGHT; - table.setLayoutData(gd); - table.setHeaderVisible(true); - table.setLinesVisible(true); - TableLayout layout = new TableLayout(); - table.setLayout(layout); - - TableColumn keyCol = new TableColumn(table, SWT.NONE); - keyCol.setText(EditorMessages.InitializationSection_MapTable_Key);//$NON-NLS-1$ - layout.addColumnData(new ColumnWeightData(1, true)); - keyCol.setResizable(true); - - TableColumn valueCol = new TableColumn(table, SWT.NONE); - layout.addColumnData(new ColumnWeightData(1, true)); - valueCol.setText(EditorMessages.InitializationSection_MapTable_Value);//$NON-NLS-1$ - valueCol.setResizable(true); - table.addMouseListener(new MouseAdapter() { - public void mouseDoubleClick(MouseEvent e) { - if (((IStructuredSelection) tableViewer.getSelection()).size() > 0) - editButtonSelected(); - } - }); - tableViewer = new TableViewer(table); - tableViewer.setContentProvider(new AdapterFactoryContentProvider( - section.getAdapterFactory())); - tableViewer.setLabelProvider(new AdapterFactoryLabelProvider(section - .getAdapterFactory())); - - tableViewer.addFilter(new ViewerFilter() { - public boolean select(Viewer viewer, Object parentElement, - Object element) { - return FacesConfigPackage.eINSTANCE.getMapEntryType() - .isInstance(element); - } - }); - - tableViewer.addSelectionChangedListener(this); - - Composite operationContainer = null; - if (toolkit != null) { - operationContainer = toolkit.createComposite(mapValueSection); - } else { - operationContainer = SWTUtils.createComposite(mapValueSection, - SWT.NONE); - } - gd = new GridData(GridData.FILL_VERTICAL); - operationContainer.setLayoutData(gd); - gl = new GridLayout(); - operationContainer.setLayout(gl); - - Button addButton = null; - if (toolkit != null) { - addButton = toolkit.createButton(operationContainer, - EditorMessages.UI_Button_Add_more, //$NON-NLS-1$ - SWT.PUSH); - } else { - addButton = SWTUtils.createPushButton(operationContainer, - EditorMessages.UI_Button_Add_more); //$NON-NLS-1$ - } - gd = new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING); - gd.grabExcessHorizontalSpace = false; - addButton.setLayoutData(gd); - - if (toolkit != null) { - editButton = toolkit.createButton(operationContainer, - EditorMessages.UI_Button_Edit_more, SWT.PUSH); - } else { - editButton = SWTUtils.createPushButton(operationContainer, - EditorMessages.UI_Button_Edit_more); //$NON-NLS-1$ - } - gd = new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING); - gd.grabExcessHorizontalSpace = false; - editButton.setLayoutData(gd); - - if (toolkit != null) { - removeButton = toolkit.createButton(operationContainer, - EditorMessages.UI_Button_Remove, //$NON-NLS-1$ - SWT.PUSH); - } else { - removeButton = SWTUtils.createPushButton(operationContainer, - EditorMessages.UI_Button_Remove); //$NON-NLS-1$ - } - gd = new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING); - gd.grabExcessHorizontalSpace = false; - removeButton.setLayoutData(gd); - addButton.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent e) { - addButtonSelected(); - } - - }); - - editButton.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent e) { - editButtonSelected(); - } - }); - removeButton.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent e) { - removeButtonSelected(); - } - }); - } - - protected void addButtonSelected() { - AddEditMapEntryDialog dialog = new AddEditMapEntryDialog(EditorPlugin - .getActiveShell(), true); - if (dialog.open() == Dialog.OK) { - MapEntryType mapEntry = FacesConfigFactory.eINSTANCE - .createMapEntryType(); - if (dialog.getKey() != null) { - KeyType key = FacesConfigFactory.eINSTANCE.createKeyType(); - key.setTextContent(dialog.getKey()); - mapEntry.setKey(key); - } - if (dialog.isNullValue()) { - NullValueType nullValue = FacesConfigFactory.eINSTANCE - .createNullValueType(); - mapEntry.setNullValue(nullValue); - } else { - ValueType value = FacesConfigFactory.eINSTANCE - .createValueType(); - value.setTextContent(dialog.getValue()); - mapEntry.setValue(value); - } - - EditingDomain editingDomain = section.getEditingDomain(); - Command command; - boolean isNewMapEntries = false; - if (managedBean.getMapEntries() == null) { - MapEntriesType mapEntriesType = FacesConfigFactory.eINSTANCE - .createMapEntriesType(); - mapEntriesType.getMapEntry().add(mapEntry); - command = SetCommand.create(editingDomain, managedBean, - FacesConfigPackage.eINSTANCE - .getManagedBeanType_MapEntries(), - mapEntriesType); - isNewMapEntries = true; - } else { - MapEntriesType mapEntries = managedBean.getMapEntries(); - - command = AddCommand.create(editingDomain, mapEntries, - FacesConfigPackage.eINSTANCE - .getMapEntriesType_MapEntry(), mapEntry); - } - - if (command.canExecute()) { - editingDomain.getCommandStack().execute(command); - if (isNewMapEntries) - refreshAll(); - } - - } - } - - protected void editButtonSelected() { - if (tableViewer.getSelection() == null - || ((IStructuredSelection) tableViewer.getSelection()) - .isEmpty()) { - return; - } - MapEntryType mapEntry = (MapEntryType) ((IStructuredSelection) tableViewer - .getSelection()).getFirstElement(); - AddEditMapEntryDialog dialog = new AddEditMapEntryDialog(EditorPlugin - .getActiveShell(), false); - if (mapEntry.getKey() != null) - dialog.setKey(mapEntry.getKey().getTextContent()); - if (mapEntry.getNullValue() != null) - dialog.setNullValue(true); - else if (mapEntry.getValue() != null) - dialog.setValue(mapEntry.getValue().getTextContent()); - - if (dialog.open() == Dialog.OK) { - EditingDomain editingDomain = section.getEditingDomain(); - List commands = new ArrayList(); - - if (mapEntry.getKey() != null) { - Command cmd1 = SetCommand.create(editingDomain, mapEntry - .getKey(), FacesConfigPackage.eINSTANCE - .getKeyType_TextContent(), dialog.getKey()); - commands.add(cmd1); - - } else { - KeyType keyType = FacesConfigFactory.eINSTANCE.createKeyType(); - keyType.setTextContent(dialog.getKey()); - Command cmd2 = SetCommand.create(editingDomain, mapEntry, - FacesConfigPackage.eINSTANCE.getMapEntryType_Key(), - keyType); - commands.add(cmd2); - } - - if (dialog.isNullValue()) { - if (mapEntry.getValue() != null) { - Command cmd3 = SetCommand.create(editingDomain, mapEntry, - FacesConfigPackage.eINSTANCE - .getMapEntryType_Value(), - SetCommand.UNSET_VALUE); - commands.add(cmd3); - } - Command cmd4 = SetCommand.create(editingDomain, mapEntry, - FacesConfigPackage.eINSTANCE - .getMapEntryType_NullValue(), - FacesConfigFactory.eINSTANCE.createNullValueType()); - - commands.add(cmd4); - } else { - if (mapEntry.getNullValue() != null) { - Command cmd5 = SetCommand.create(editingDomain, mapEntry, - FacesConfigPackage.eINSTANCE - .getMapEntryType_NullValue(), - SetCommand.UNSET_VALUE); - commands.add(cmd5); - } - - if (mapEntry.getValue() != null) { - Command cmd6 = SetCommand.create(editingDomain, mapEntry - .getValue(), FacesConfigPackage.eINSTANCE - .getValueType_TextContent(), dialog.getValue()); - commands.add(cmd6); - } else { - ValueType value = FacesConfigFactory.eINSTANCE - .createValueType(); - value.setTextContent(dialog.getValue()); - Command cmd7 = SetCommand.create(editingDomain, mapEntry, - FacesConfigPackage.eINSTANCE - .getMapEntryType_Value(), value); - commands.add(cmd7); - } - - } - - Command command = new CompoundCommand(commands); - if (command.canExecute()) { - editingDomain.getCommandStack().execute(command); - tableViewer.refresh(mapEntry); - } - - } - - } - - protected void removeButtonSelected() { - - MapEntryType mapEntry = (MapEntryType) ((IStructuredSelection) tableViewer - .getSelection()).getFirstElement(); - EditingDomain editingDomain = section.getEditingDomain(); - Command cmd = RemoveCommand.create(editingDomain, mapEntry); - if (cmd.canExecute()) { - editingDomain.getCommandStack().execute(cmd); - refresh(); - } - } - - /** - * get the project according to current xml node. - * - * @return - */ - private IProject getProject() { - if (currentProject == null) { - currentProject = (IProject) section.getPage().getEditor() - .getAdapter(IProject.class); - } - return currentProject; - } - - public void setProject(IProject project) { - currentProject = project; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.common.dialogfield.DialogFieldGroup#validateDialogFields() - */ - public IStatus[] validateDialogFields() { - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.section.IDialogFieldGroup#setInput(java.lang.Object) - */ - public void setInput(Object newInput) { - if (newInput != null && newInput instanceof ManagedBeanType) { - managedBean = (ManagedBeanType) newInput; - if (managedBean.getMapEntries() != null) - refreshAll(); - } - } - - public void refreshAll() { - if (managedBean.getMapEntries() != null - && managedBean.getMapEntries().getKeyClass() != null) { - this.keyClassField.setTextWithoutUpdate(managedBean.getMapEntries() - .getKeyClass().getTextContent()); - } else { - this.keyClassField.setTextWithoutUpdate(null); - } - - if (managedBean.getMapEntries() != null - && managedBean.getMapEntries().getValueClass() != null) { - this.valueClassField.setTextWithoutUpdate(managedBean - .getMapEntries().getValueClass().getTextContent()); - } else { - this.valueClassField.setTextWithoutUpdate(null); - } - - tableViewer.setInput(((ManagedBeanType) getInput()).getMapEntries()); - updateButtons(); - } - - public Object getInput() { - return this.managedBean; - } - - public void refreshData() { - refresh(); - - } - - /** - * - */ - public void refresh() { - tableViewer.refresh(); - updateButtons(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ISelectionProvider#addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) - */ - public void addSelectionChangedListener(ISelectionChangedListener listener) { - selectionChangedListeners.add(listener); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection() - */ - public ISelection getSelection() { - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ISelectionProvider#removeSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) - */ - public void removeSelectionChangedListener( - ISelectionChangedListener listener) { - selectionChangedListeners.remove(listener); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection) - */ - public void setSelection(ISelection selection) { - // do nothing - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) - */ - public void selectionChanged(SelectionChangedEvent event) { - for (Iterator listeners = selectionChangedListeners.iterator(); listeners - .hasNext();) { - ISelectionChangedListener listener = (ISelectionChangedListener) listeners - .next(); - listener.selectionChanged(new SelectionChangedEvent(this, event - .getSelection())); - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/OthersPageBaseSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/OthersPageBaseSection.java deleted file mode 100644 index 1d1d31243..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/OthersPageBaseSection.java +++ /dev/null @@ -1,315 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.section; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.common.command.CompoundCommand; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.edit.command.RemoveCommand; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.jst.jsf.facesconfig.ui.page.IFacesConfigPage; -import org.eclipse.jst.jsf.facesconfig.ui.page.OthersPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * @author Zhi-peng Zhang - * @version - */ -/** - * The base class for the Sections in Others Page. - */ -public abstract class OthersPageBaseSection extends AbstractFacesConfigSection { - - /** - * Table viewer for all sections based on this calss - */ - protected TableViewer tableViewer; - - private Button removeButton; - - /** - * - * @param parent - * @param managedForm - * @param page - * @param toolkit - * @param helpContextId - * @param helpTooltip - */ - public OthersPageBaseSection(Composite parent, IManagedForm managedForm, - IFacesConfigPage page, FormToolkit toolkit, String helpContextId, - String helpTooltip) { - super(parent, managedForm, page, toolkit, helpContextId, helpTooltip); - } - - /** - * @param parent - * @param managedForm - * @param page - * @param toolkit - */ - public OthersPageBaseSection(Composite parent, IManagedForm managedForm, - IFacesConfigPage page, FormToolkit toolkit) { - this(parent, managedForm, page, toolkit, null, null); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.section.AbstractFacesConfigSection#createContents(org.eclipse.swt.widgets.Composite, - * org.eclipse.ui.forms.widgets.FormToolkit) - */ - protected void createContents(Composite container, FormToolkit toolkit) { - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - layout.marginWidth = layout.marginHeight = 5; - container.setLayout(layout); - createViewer(container, toolkit); - createOperationSection(container, toolkit); - } - - /** - * create TableViewer for this section. sub-class may override it to return - * a new type tableViewer. for example CheckboxTableViewer. - * - * @param parent - * @return the table viewer for this section - */ - protected TableViewer createTableViewer(Composite parent) { - return new TableViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL - | SWT.BORDER); - } - - /** - * Config the viewer, such as set a filter and so on. Sub classes should - * override this method to add filter. - * - * @param tableViewer1 - */ - protected abstract void configTableViewer(TableViewer tableViewer1); - - /** - * - * @param parent - * @param toolkit - */ - protected void createViewer(Composite parent, FormToolkit toolkit) { - Composite tableContainer = toolkit.createComposite(parent); - toolkit.paintBordersFor(tableContainer); - - GridData gd = new GridData(GridData.FILL_BOTH); - gd.heightHint = 200; - tableContainer.setLayoutData(gd); - tableContainer.setLayout(new GridLayout()); - - tableViewer = createTableViewer(tableContainer); - tableViewer.getControl() - .setLayoutData(new GridData(GridData.FILL_BOTH)); - tableViewer.setContentProvider(new AdapterFactoryContentProvider( - getAdapterFactory())); - tableViewer.setLabelProvider(new AdapterFactoryLabelProvider( - getAdapterFactory())); - configTableViewer(tableViewer); - - tableViewer.addSelectionChangedListener(this); - } - - /** - * - * @param parent - * @param toolkit - */ - protected void createOperationSection(Composite parent, FormToolkit toolkit) { - Composite operationContainer = toolkit.createComposite(parent); - operationContainer.setLayoutData(new GridData(GridData.FILL_VERTICAL)); - - operationContainer.setLayout(new GridLayout()); - - Button addButton = toolkit.createButton(operationContainer, - EditorMessages.UI_Button_Add, SWT.PUSH); - GridData gd = new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING); - gd.grabExcessHorizontalSpace = false; - addButton.setLayoutData(gd); - - addButton.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - addButtonSelected(e); - } - - public void widgetDefaultSelected(SelectionEvent e) { - addButtonSelected(e); - } - }); - - setRemoveButton(toolkit.createButton(operationContainer, - EditorMessages.UI_Button_Remove, SWT.PUSH)); - - getRemoveButton().setEnabled(true); - gd = new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING); - gd.grabExcessHorizontalSpace = false; - getRemoveButton().setLayoutData(gd); - getRemoveButton().addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - removeButtonSelected(e); - } - - public void widgetDefaultSelected(SelectionEvent e) { - removeButtonSelected(e); - } - }); - } - - - abstract void addButtonSelected(SelectionEvent e); - - /** - * Respond to selection of the remove button - * @param e - */ - protected void removeButtonSelected(SelectionEvent e) { - IStructuredSelection ssel = StructuredSelection.EMPTY; - ISelection selection = getSelection(); - if (selection instanceof IStructuredSelection) { - ssel = (IStructuredSelection) selection; - } - - if (!ssel.isEmpty()) { - List commands = new ArrayList(ssel.size()); - for (Iterator iter = ssel.iterator(); iter.hasNext();) { - EObject element = (EObject) iter.next(); - if (element.eContainer().eContents().size() == 1) { - // if the parent only have this one child, then remove it - // together. - element = element.eContainer(); - } - Command command = RemoveCommand.create(getEditingDomain(), - element); - commands.add(command); - - } - - CompoundCommand command = new CompoundCommand(commands); - if (command.canExecute()) { - getEditingDomain().getCommandStack().execute(command); - } - } - } - - public ISelection getSelection() { - return tableViewer.getSelection(); - } - - /** - * update all buttons with the current selection - */ - protected void updateButtons() { - if (!getRemoveButton().isDisposed()) { - IStructuredSelection ssel = (IStructuredSelection) getSelection(); - getRemoveButton().setEnabled(!ssel.isEmpty()); - } - } - - public void refresh() { - super.refresh(); - tableViewer.refresh(); - updateButtons(); - } - - public void setSelection(ISelection selection) { - tableViewer.setSelection(selection); - } - - /** - * @return Returns the tableViewer. - */ - public TableViewer getTableViewer() { - return tableViewer; - } - - public void refreshAll() { - setViewerInput(getInput()); - updateButtons(); - } - - /** - * set the structuredViewer's input - * - * @param input - */ - abstract protected void setViewerInput(Object input); - - public void expansionStateChanged(boolean expanded) { - if (expanded) { - if (tableViewer.getInput() == null) { - refreshAll(); - } - tableViewer.setSelection(tableViewer.getSelection()); - } else { - tableViewer.setSelection(null); - } - super.expansionStateChanged(expanded); - } - - protected void expansionStateChanging(boolean expanding) { - if (!expanding) { - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - this.getSection().setLayoutData(gd); - } else { - ((OthersPage) getPage()).closeOtherSections(this); - - GridData gd = new GridData(GridData.FILL_BOTH); - this.getSection().setLayoutData(gd); - } - - super.expansionStateChanging(expanding); - } - - public void selectionChanged(SelectionChangedEvent event) { - super.selectionChanged(event); - updateButtons(); - } - - /** - * @param removeButton - */ - protected void setRemoveButton(Button removeButton) { - this.removeButton = removeButton; - } - - /** - * @return the button widget - */ - protected Button getRemoveButton() { - return removeButton; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/OverviewComponentsSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/OverviewComponentsSection.java deleted file mode 100644 index c7f5016eb..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/OverviewComponentsSection.java +++ /dev/null @@ -1,107 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.section; - -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.jst.jsf.facesconfig.ui.page.ComponentsPage; -import org.eclipse.jst.jsf.facesconfig.ui.page.IFacesConfigPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * @author sfshi - * @version - */ -public class OverviewComponentsSection extends AbstractOverviewSection { - - /** - * - * @param parent - * @param managedForm - * @param page - * @param toolkit - */ - public OverviewComponentsSection(Composite parent, - IManagedForm managedForm, IFacesConfigPage page, FormToolkit toolkit) { - super(parent, managedForm, page, toolkit, ComponentsPage.PAGE_ID, - EditorMessages.OverviewPage_ComponentsSection_name, - EditorMessages.OverviewPage_ComponentsSection_description, - null, null); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.section.AbstractOverviewSection#configTableViewer(org.eclipse.jface.viewers.TableViewer) - */ - protected void configTableViewer(TableViewer tableViewer1) { - tableViewer1.addFilter(new ViewerFilter() { - public boolean select(Viewer viewer, Object parentElement, - Object element) { - return FacesConfigPackage.eINSTANCE.getComponentType() - .isInstance(element) - || FacesConfigPackage.eINSTANCE.getConverterType() - .isInstance(element) - || FacesConfigPackage.eINSTANCE.getRenderKitType() - .isInstance(element) - || FacesConfigPackage.eINSTANCE.getValidatorType() - .isInstance(element); - } - }); - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.section.AbstractOverviewSection#createTable(org.eclipse.swt.widgets.Composite) - */ - protected Table createTable(Composite container) { - Table table = new Table(container, SWT.H_SCROLL | SWT.V_SCROLL - | SWT.FULL_SELECTION | SWT.BORDER); - - GridData gd = new GridData(GridData.FILL_BOTH); - gd.horizontalSpan = 1; - gd.heightHint = 100; - table.setLayoutData(gd); - - table.setLinesVisible(true); - table.setHeaderVisible(true); - TableLayout tablelayout = new TableLayout(); - table.setLayout(tablelayout); - - TableColumn typecol = new TableColumn(table, SWT.LEFT); - tablelayout.addColumnData(new ColumnWeightData(1, true)); - typecol - .setText(EditorMessages.OverviewPage_ComponentsSection_table_typecol); - typecol.setResizable(true); - - TableColumn namecol = new TableColumn(table, SWT.LEFT); - tablelayout.addColumnData(new ColumnWeightData(1, true)); - namecol - .setText(EditorMessages.OverviewPage_ComponentsSection_table_namecol); - namecol.setResizable(true); - - return table; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/OverviewGeneralSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/OverviewGeneralSection.java deleted file mode 100644 index c19346d49..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/OverviewGeneralSection.java +++ /dev/null @@ -1,116 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.section; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.jst.jsf.facesconfig.ui.page.IFacesConfigPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.part.FileEditorInput; - -/** - * @author jchoi, Xiao-guang Zhang - * @version - */ -public class OverviewGeneralSection extends AbstractFacesConfigSection { - - private Text versionText; - - /** - * @param parent - * @param managedForm - * @param page - * @param toolkit - */ - public OverviewGeneralSection(Composite parent, IManagedForm managedForm, - IFacesConfigPage page, FormToolkit toolkit) { - super(parent, managedForm, page, toolkit, null, null); - - getSection().setText( - EditorMessages.OverviewPage_GeneralSection_name); //$NON-NLS-1$ - getSection().setDescription( - EditorMessages.OverviewPage_GeneralSection_description); //$NON-NLS-1$ - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.update.ui.forms.internal.FormSection#createClient(org.eclipse.swt.widgets.Composite, - * org.eclipse.update.ui.forms.internal.FormWidgetFactory) - */ - public void createContents(Composite container, FormToolkit toolkit) { - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - container.setLayout(layout); - - IEditorInput editorInput = this.getPage().getEditor().getEditorInput(); - - toolkit.createLabel(container, - EditorMessages.OverviewPage_GeneralSection_label_name); //$NON-NLS-1$ - Text typeText = toolkit.createText(container, ((FileEditorInput)editorInput).getName()); - typeText.setEditable(false); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - typeText.setLayoutData(data); - - toolkit.createLabel(container, - EditorMessages.OverviewPage_GeneralSection_label_version); //$NON-NLS-1$ - versionText = toolkit.createText(container, ""); - versionText.setLayoutData(data); - versionText.setEditable(false); - - // set the service type description - data = new GridData(GridData.FILL_HORIZONTAL); - versionText.setLayoutData(data); - - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan = 2; - Label sep = toolkit.createSeparator(container, SWT.HORIZONTAL); - sep.setLayoutData(gd); - toolkit.paintBordersFor(container); - - // return container; - } - - public void refreshAll() { - if (getInput() == null || !(getInput() instanceof EObject)) { - return; - } - -// FacesConfigType facesConfig = (FacesConfigType)getInput(); - // TODO get the version and display it. - // String version = FacesConfigUtil - // .getFacesConfigVersion((IDOMModel) getInput()); - // - // if (null == version) { - // Document document = ((IDOMModel) getInput()).getDocument(); - // DocumentType doctype = document.getDoctype(); - // if (doctype != null) { - // String pid = doctype.getPublicId(); - // version = pid.substring(PUBLIC_ID.length() + 1); - // version = version.substring(version.indexOf(VERSION_PREFIX) - // + VERSION_PREFIX.length() + 1, version.indexOf("//")); - // } - // if (null == version) { - // version = ""; - // } - // } - // versionText.setText(version); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/OverviewManagedBeanSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/OverviewManagedBeanSection.java deleted file mode 100644 index c0662463d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/OverviewManagedBeanSection.java +++ /dev/null @@ -1,109 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.section; - -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.jst.jsf.facesconfig.ui.page.IFacesConfigPage; -import org.eclipse.jst.jsf.facesconfig.ui.page.ManagedBeanPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * @author sfshi - * @version - */ -public class OverviewManagedBeanSection extends AbstractOverviewSection { - - - /** - * - * @param parent - * @param managedForm - * @param page - * @param toolkit - */ - public OverviewManagedBeanSection(Composite parent, - IManagedForm managedForm, IFacesConfigPage page, FormToolkit toolkit) { - super(parent, managedForm, page, toolkit, ManagedBeanPage.PAGE_ID, - EditorMessages.OverviewPage_ManagedBeanSection_name, - EditorMessages.OverviewPage_ManagedBeanSection_description, - null, null); - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.section.AbstractOverviewSection#configTableViewer(org.eclipse.jface.viewers.TableViewer) - */ - protected void configTableViewer(TableViewer tableViewer1) { - tableViewer1.addFilter(new ViewerFilter() { - public boolean select(Viewer viewer, Object parentElement, - Object element) { - return FacesConfigPackage.eINSTANCE.getManagedBeanType() - .isInstance(element); - } - }); - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.section.AbstractOverviewSection#createTable() - */ - protected Table createTable(Composite container) { - Table table = new Table(container, SWT.H_SCROLL | SWT.V_SCROLL - | SWT.FULL_SELECTION | SWT.BORDER); - - GridData gd = new GridData(GridData.FILL_BOTH); - gd.horizontalSpan = 1; - gd.heightHint = 100; - table.setLayoutData(gd); - - table.setLinesVisible(true); - table.setHeaderVisible(true); - TableLayout tablelayout = new TableLayout(); - table.setLayout(tablelayout); - - TableColumn namecol = new TableColumn(table, SWT.LEFT); - namecol - .setText(EditorMessages.OverviewPage_ManagedBeanSection_table_namecol); - tablelayout.addColumnData(new ColumnWeightData(1, true)); - namecol.setResizable(true); - - TableColumn scopecol = new TableColumn(table, SWT.LEFT); - scopecol - .setText(EditorMessages.OverviewPage_ManagedBeanSection_table_scopecol); - tablelayout.addColumnData(new ColumnWeightData(1, true)); - scopecol.setResizable(true); - - TableColumn classcol = new TableColumn(table, SWT.LEFT); - classcol - .setText(EditorMessages.OverviewPage_ManagedBeanSection_table_classcol); - tablelayout.addColumnData(new ColumnWeightData(1, true)); - classcol.setResizable(true); - - return table; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/OverviewNavigationSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/OverviewNavigationSection.java deleted file mode 100644 index 05a63c404..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/OverviewNavigationSection.java +++ /dev/null @@ -1,381 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.section; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.impl.AdapterImpl; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigType; -import org.eclipse.jst.jsf.facesconfig.emf.NavigationCaseType; -import org.eclipse.jst.jsf.facesconfig.emf.NavigationRuleType; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.jst.jsf.facesconfig.ui.page.IFacesConfigPage; -import org.eclipse.jst.jsf.facesconfig.ui.pageflow.PageflowEditor; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * @author sfshi - * - */ -public class OverviewNavigationSection extends AbstractOverviewSection { - - private static final int COLUMN_WITH = 70; - - private OverviewNavigationSectionAdapter overviewNavigationSectionAdapter; - - /** - * - * @param parent - * @param managedForm - * @param page - * @param toolkit - */ - public OverviewNavigationSection(Composite parent, - IManagedForm managedForm, IFacesConfigPage page, FormToolkit toolkit) { - super(parent, managedForm, page, toolkit, PageflowEditor.PAGE_ID, - EditorMessages.OverviewPage_NavigationSection_name, - EditorMessages.OverviewPage_NavigationSection_description, - null, null); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.section.AbstractOverviewSection#configTableViewer(org.eclipse.jface.viewers.TableViewer) - */ - protected void configTableViewer(TableViewer tableViewer1) { - tableViewer1.setContentProvider(new IStructuredContentProvider() { - - public Object[] getElements(Object inputElement) { - List navigationCaseList = (List) inputElement; - return navigationCaseList.toArray(); - } - - public void dispose() { - // nothing to dispose - } - - public void inputChanged(Viewer viewer, Object oldInput, - Object newInput) { - // do nothing - } - }); - - tableViewer1.setLabelProvider(new ITableLabelProvider() { - - public Image getColumnImage(Object element, int columnIndex) { - return null; - } - - public String getColumnText(Object element, int columnIndex) { - NavigationCaseType navigationCase = (NavigationCaseType) element; - switch (columnIndex) { - - case 0: - return ((NavigationRuleType) navigationCase.eContainer()) - .getFromViewId() == null ? "" - : ((NavigationRuleType) navigationCase.eContainer()) - .getFromViewId().getTextContent(); - - case 1: - return navigationCase.getFromOutcome() == null ? "" - : navigationCase.getFromOutcome().getTextContent(); - - case 2: - return navigationCase.getToViewId() == null ? "" - : navigationCase.getToViewId().getTextContent(); - } - return null; - } - - public void addListener(ILabelProviderListener listener) { - // no listeners? - } - - public void dispose() { - // do nothing - } - - public boolean isLabelProperty(Object element, String property) { - return false; - } - - public void removeListener(ILabelProviderListener listener) { - // no listeners? - } - }); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.section.AbstractOverviewSection#createTable(org.eclipse.swt.widgets.Composite) - */ - protected Table createTable(Composite container) { - Table table = new Table(container, SWT.H_SCROLL | SWT.V_SCROLL - | SWT.FULL_SELECTION | SWT.BORDER | SWT.BORDER); - - GridData gd = new GridData(GridData.FILL_BOTH); - gd.horizontalSpan = 1; - gd.heightHint = 100; - table.setLayoutData(gd); - - table.setLinesVisible(true); - table.setHeaderVisible(true); - TableLayout tablelayout = new TableLayout(); - table.setLayout(tablelayout); - - TableColumn column1 = new TableColumn(table, SWT.LEFT); - column1 - .setText(EditorMessages.OverviewPage_NavigationSection_table_col1); - // column1.setWidth(COLUMN_WITH); - tablelayout.addColumnData(new ColumnWeightData(1, COLUMN_WITH, true)); - // tablelayout.addColumnData(new ColumnWeightData(1, true)); - column1.setResizable(true); - - TableColumn column2 = new TableColumn(table, SWT.LEFT); - column2 - .setText(EditorMessages.OverviewPage_NavigationSection_table_col2); - tablelayout.addColumnData(new ColumnWeightData(1, COLUMN_WITH, true)); - // tablelayout.addColumnData(new ColumnWeightData(1, true)); - column2.setResizable(true); - // column2.setWidth(COLUMN_WITH); - - TableColumn column3 = new TableColumn(table, SWT.LEFT); - column3 - .setText(EditorMessages.OverviewPage_NavigationSection_table_col3); - tablelayout.addColumnData(new ColumnWeightData(1, COLUMN_WITH, true)); - // tablelayout.addColumnData(new ColumnWeightData(1, true)); - column3.setResizable(true); - // column3.setWidth(COLUMN_WITH); - - return table; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.section.IFacesConfigSection#refreshAll() - */ - public void refreshAll() { - List navigationCaseList = new ArrayList(); - if (getInput() instanceof FacesConfigType) { - List navigationRules = ((FacesConfigType) getInput()) - .getNavigationRule(); - for (int i = 0, n = navigationRules.size(); i < n; i++) { - NavigationRuleType navigationRule = (NavigationRuleType) navigationRules - .get(i); - navigationCaseList.addAll(navigationRule.getNavigationCase()); - } - } - - tableViewer.setInput(navigationCaseList); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.section.AbstractFacesConfigSection#addAdaptersOntoInput(java.lang.Object) - */ - protected void addAdaptersOntoInput(Object newInput) { - FacesConfigType facesConfig = (FacesConfigType) newInput; - addOverviewNavigationSectionAdapter(facesConfig); - - for (Iterator it = facesConfig.getNavigationRule().iterator(); it - .hasNext();) { - NavigationRuleType navigationRule = (NavigationRuleType) it.next(); - - addOverviewNavigationSectionAdapter(navigationRule); - - if (navigationRule.getFromViewId() != null) { - addOverviewNavigationSectionAdapter(navigationRule - .getFromViewId()); - } - - for (Iterator it2 = navigationRule.getNavigationCase().iterator(); it2 - .hasNext();) { - NavigationCaseType navigationCase = (NavigationCaseType) it2 - .next(); - addOverviewNavigationSectionAdapter(navigationCase); - - if (navigationCase.getFromOutcome() != null) { - addOverviewNavigationSectionAdapter(navigationCase - .getFromOutcome()); - } - - if (navigationCase.getToViewId() != null) { - addOverviewNavigationSectionAdapter(navigationCase - .getToViewId()); - } - } - } - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.section.AbstractFacesConfigSection#removeAdaptersFromInput(java.lang.Object) - */ - protected void removeAdaptersFromInput(Object oldInput) { - super.removeAdaptersFromInput(oldInput); - - FacesConfigType facesConfig = (FacesConfigType) oldInput; - removeOverviewNavigationSectionAdapter(facesConfig); - - for (Iterator it = facesConfig.getNavigationRule().iterator(); it - .hasNext();) { - NavigationRuleType navigationRule = (NavigationRuleType) it.next(); - - removeOverviewNavigationSectionAdapter(navigationRule); - - if (navigationRule.getFromViewId() != null) { - removeOverviewNavigationSectionAdapter(navigationRule - .getFromViewId()); - } - - for (Iterator it2 = navigationRule.getNavigationCase().iterator(); it2 - .hasNext();) { - NavigationCaseType navigationCase = (NavigationCaseType) it2 - .next(); - removeOverviewNavigationSectionAdapter(navigationCase); - - if (navigationCase.getFromOutcome() != null) { - removeOverviewNavigationSectionAdapter(navigationCase - .getFromOutcome()); - } - - if (navigationCase.getToViewId() != null) { - removeOverviewNavigationSectionAdapter(navigationCase - .getToViewId()); - } - } - } - - } - - protected void addOverviewNavigationSectionAdapter(EObject object) { - if (EcoreUtil.getExistingAdapter(object, - OverviewNavigationSection.class) == null) { - object.eAdapters().add(getOverviewNavigationSectionAdapter()); - } - - } - - protected void removeOverviewNavigationSectionAdapter(EObject object) { - if (EcoreUtil.getExistingAdapter(object, - OverviewNavigationSection.class) != null) { - object.eAdapters().remove(getOverviewNavigationSectionAdapter()); - } - } - - protected OverviewNavigationSectionAdapter getOverviewNavigationSectionAdapter() { - if (overviewNavigationSectionAdapter == null) - overviewNavigationSectionAdapter = new OverviewNavigationSectionAdapter(); - return overviewNavigationSectionAdapter; - } - - class OverviewNavigationSectionAdapter extends AdapterImpl { - - public boolean isAdapterForType(Object type) { - if (type == OverviewNavigationSection.class) - return true; - return false; - } - - public void notifyChanged(Notification msg) { - - if ((msg.getFeature() == FacesConfigPackage.eINSTANCE - .getFacesConfigType_NavigationRule() - || msg.getFeature() == FacesConfigPackage.eINSTANCE - .getNavigationRuleType_NavigationCase() - || msg.getFeature() == FacesConfigPackage.eINSTANCE - .getNavigationRuleType_FromViewId() || msg - .getFeature() == FacesConfigPackage.eINSTANCE - .getFromViewIdType_TextContent())) { - if (msg.getEventType() == Notification.ADD - || msg.getEventType() == Notification.SET) { - if (msg.getNewValue() instanceof EObject) { - EObject newObject = (EObject) msg.getNewValue(); - addOverviewNavigationSectionAdapter(newObject); - } - } - if (msg.getEventType() == Notification.ADD - || msg.getEventType() == Notification.REMOVE - || msg.getEventType() == Notification.SET) - refreshAll(); - return; - } - - if (msg.getFeature() == FacesConfigPackage.eINSTANCE - .getNavigationCaseType_FromOutcome() - || msg.getFeature() == FacesConfigPackage.eINSTANCE - .getNavigationCaseType_ToViewId()) { - - if (msg.getEventType() == Notification.ADD - || msg.getEventType() == Notification.SET) { - if (msg.getNewValue() instanceof EObject) { - EObject newObject = (EObject) msg.getNewValue(); - addOverviewNavigationSectionAdapter(newObject); - } - } - if (msg.getEventType() == Notification.ADD - - || msg.getEventType() == Notification.REMOVE - || msg.getEventType() == Notification.SET) { - - NavigationCaseType navigationCase = (NavigationCaseType) msg - .getNotifier(); - tableViewer.refresh(navigationCase); - } - return; - } - - if (msg.getFeature() == FacesConfigPackage.eINSTANCE - .getFromOutcomeType_TextContent() - || msg.getFeature() == FacesConfigPackage.eINSTANCE - .getToViewIdType_TextContent()) { - - if (msg.getEventType() == Notification.ADD - || msg.getEventType() == Notification.REMOVE - || msg.getEventType() == Notification.SET) { - NavigationCaseType navigationCase = (NavigationCaseType) ((EObject) msg - .getNotifier()).eContainer(); - tableViewer.refresh(navigationCase); - } - return; - } - - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/OverviewOthersSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/OverviewOthersSection.java deleted file mode 100644 index 2ca48678f..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/OverviewOthersSection.java +++ /dev/null @@ -1,350 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.section; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.impl.AdapterImpl; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jst.jsf.facesconfig.emf.ApplicationType; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigType; -import org.eclipse.jst.jsf.facesconfig.emf.FactoryType; -import org.eclipse.jst.jsf.facesconfig.emf.LifecycleType; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.jst.jsf.facesconfig.ui.page.IFacesConfigPage; -import org.eclipse.jst.jsf.facesconfig.ui.page.OthersPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * @author sfshi - * - */ -public class OverviewOthersSection extends AbstractOverviewSection { - - private static final int COLUMN_WITH = 100; - - private OverviewOthersSectionAdapter overviewOthersSectionAdapter; - - /** - * - * @param parent - * @param managedForm - * @param page - * @param toolkit - */ - public OverviewOthersSection(Composite parent, IManagedForm managedForm, - IFacesConfigPage page, FormToolkit toolkit) { - super(parent, managedForm, page, toolkit, OthersPage.PAGE_ID, - EditorMessages.OverviewPage_OthersSection_name, - EditorMessages.OverviewPage_OthersSection_description, - null, null); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.section.AbstractOverviewSection#configTableViewer(org.eclipse.jface.viewers.TableViewer) - */ - protected void configTableViewer(TableViewer tableViewer1) { - tableViewer1.setContentProvider(new IStructuredContentProvider() { - - public Object[] getElements(Object inputElement) { - List othersNodesList = (List) inputElement; - return othersNodesList.toArray(); - } - - public void dispose() { - // do nothing - } - - public void inputChanged(Viewer viewer, Object oldInput, - Object newInput) { - // do nothing - } - }); - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.section.AbstractOverviewSection#createTable(org.eclipse.swt.widgets.Composite) - */ - protected Table createTable(Composite container) { - Table table = new Table(container, SWT.H_SCROLL | SWT.V_SCROLL - | SWT.FULL_SELECTION | SWT.BORDER); - - GridData gd = new GridData(GridData.FILL_BOTH); - gd.horizontalSpan = 1; - gd.heightHint = 100; - table.setLayoutData(gd); - - table.setLinesVisible(true); - table.setHeaderVisible(true); - TableLayout tablelayout = new TableLayout(); - table.setLayout(tablelayout); - - TableColumn valuecol = new TableColumn(table, SWT.NONE); - tablelayout.addColumnData(new ColumnWeightData(1, COLUMN_WITH, true)); - valuecol - .setText(EditorMessages.OverviewPage_OthersSection_table_valuecol); - valuecol.setResizable(true); - - TableColumn typecol = new TableColumn(table, SWT.NONE); - tablelayout.addColumnData(new ColumnWeightData(1, COLUMN_WITH, true)); - typecol - .setText(EditorMessages.OverviewPage_OthersSection_table_typecol); - typecol.setResizable(true); - - return table; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.section.AbstractOverviewSection#refreshAll() - */ - public void refreshAll() { - - List othersNodesList = new ArrayList(); - if (getInput() instanceof FacesConfigType) { - Object[] applicationNodes = null; - Object[] factoryNodes = null; - Object[] lifecycleNodes = null; - FacesConfigType facesConfig = (FacesConfigType) getInput(); - IStructuredContentProvider contentProvider = new AdapterFactoryContentProvider( - getAdapterFactory()); - if (facesConfig.getApplication().size() > 0) { - - ApplicationType application = (ApplicationType) facesConfig - .getApplication().get(0); - applicationNodes = contentProvider.getElements(application); - - } - - if (facesConfig.getFactory().size() > 0) { - FactoryType factory = (FactoryType) facesConfig.getFactory() - .get(0); - factoryNodes = contentProvider.getElements(factory); - } - - if (facesConfig.getLifecycle().size() > 0) { - LifecycleType lifecycle = (LifecycleType) facesConfig - .getLifecycle().get(0); - lifecycleNodes = contentProvider.getElements(lifecycle); - } - - if (applicationNodes != null) { - for (int i = 0, n = applicationNodes.length; i < n; i++) { - othersNodesList.add(applicationNodes[i]); - } - } - - if (factoryNodes != null) { - for (int i = 0, n = factoryNodes.length; i < n; i++) { - othersNodesList.add(factoryNodes[i]); - } - } - - if (lifecycleNodes != null) { - for (int i = 0, n = lifecycleNodes.length; i < n; i++) { - othersNodesList.add(lifecycleNodes[i]); - } - } - } - - tableViewer.setInput(othersNodesList); - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.section.AbstractFacesConfigSection#addAdaptersOntoInput(java.lang.Object) - */ - protected void addAdaptersOntoInput(Object newInput) { - FacesConfigType facesConfig = (FacesConfigType) newInput; - addOverviewOthersSectionAdapter(facesConfig); - IStructuredContentProvider contentProvider = new AdapterFactoryContentProvider( - getAdapterFactory()); - if (facesConfig.getApplication().size() > 0) { - ApplicationType application = (ApplicationType) facesConfig - .getApplication().get(0); - addOverviewOthersSectionAdapter(application); - - Object[] applicationNodes = contentProvider - .getElements(application); - for (int i = 0, n = applicationNodes.length; i < n; i++) { - addOverviewOthersSectionAdapter((EObject) applicationNodes[i]); - } - - } - - if (facesConfig.getFactory().size() > 0) { - FactoryType factory = (FactoryType) facesConfig.getFactory().get(0); - addOverviewOthersSectionAdapter(factory); - - Object[] factoryNodes = contentProvider.getElements(factory); - for (int i = 0, n = factoryNodes.length; i < n; i++) { - addOverviewOthersSectionAdapter((EObject) factoryNodes[i]); - } - - } - - if (facesConfig.getLifecycle().size() > 0) { - LifecycleType lifecycle = (LifecycleType) facesConfig - .getLifecycle().get(0); - addOverviewOthersSectionAdapter(lifecycle); - - Object[] lifecycleNodes = contentProvider.getElements(lifecycle); - for (int i = 0, n = lifecycleNodes.length; i < n; i++) { - addOverviewOthersSectionAdapter((EObject) lifecycleNodes[i]); - } - - } - - } - - protected void addOverviewOthersSectionAdapter(EObject object) { - if (EcoreUtil.getExistingAdapter(object, OverviewOthersSection.class) == null) { - object.eAdapters().add(getOverviewOthersSectionAdapter()); - } - - } - - protected void removeOverviewOthersSectionAdapter(EObject object) { - if (EcoreUtil.getExistingAdapter(object, OverviewOthersSection.class) != null) { - object.eAdapters().remove(getOverviewOthersSectionAdapter()); - } - } - - protected OverviewOthersSectionAdapter getOverviewOthersSectionAdapter() { - if (overviewOthersSectionAdapter == null) { - overviewOthersSectionAdapter = new OverviewOthersSectionAdapter(); - } - - return overviewOthersSectionAdapter; - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.section.AbstractFacesConfigSection#removeAdaptersFromInput(java.lang.Object) - */ - protected void removeAdaptersFromInput(Object oldInput) { - - FacesConfigType facesConfig = (FacesConfigType) oldInput; - removeOverviewOthersSectionAdapter(facesConfig); - IStructuredContentProvider contentProvider = new AdapterFactoryContentProvider( - getAdapterFactory()); - if (facesConfig.getApplication().size() > 0) { - ApplicationType application = (ApplicationType) facesConfig - .getApplication().get(0); - removeOverviewOthersSectionAdapter(application); - - Object[] applicationNodes = contentProvider - .getElements(application); - for (int i = 0, n = applicationNodes.length; i < n; i++) { - removeOverviewOthersSectionAdapter((EObject) applicationNodes[i]); - } - - } - - if (facesConfig.getFactory().size() > 0) { - FactoryType factory = (FactoryType) facesConfig.getFactory().get(0); - removeOverviewOthersSectionAdapter(factory); - - Object[] factoryNodes = contentProvider.getElements(factory); - for (int i = 0, n = factoryNodes.length; i < n; i++) { - removeOverviewOthersSectionAdapter((EObject) factoryNodes[i]); - } - - } - - if (facesConfig.getLifecycle().size() > 0) { - LifecycleType lifecycle = (LifecycleType) facesConfig - .getLifecycle().get(0); - removeOverviewOthersSectionAdapter(lifecycle); - - Object[] lifecycleNodes = contentProvider.getElements(lifecycle); - for (int i = 0, n = lifecycleNodes.length; i < n; i++) { - removeOverviewOthersSectionAdapter((EObject) lifecycleNodes[i]); - } - - } - - } - - class OverviewOthersSectionAdapter extends AdapterImpl { - - /* - * (non-Javadoc) - * - * @see org.eclipse.emf.common.notify.impl.AdapterImpl#isAdapterForType(java.lang.Object) - */ - public boolean isAdapterForType(Object type) { - if (type == OverviewOthersSection.class) - return true; - return false; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.emf.common.notify.impl.AdapterImpl#notifyChanged(org.eclipse.emf.common.notify.Notification) - */ - public void notifyChanged(Notification msg) { - if (msg.getFeature() == FacesConfigPackage.eINSTANCE - .getFacesConfigType_Application() - || msg.getFeature() == FacesConfigPackage.eINSTANCE - .getFacesConfigType_Factory() - || msg.getFeature() == FacesConfigPackage.eINSTANCE - .getFacesConfigType_Lifecycle() - || msg.getNotifier() instanceof ApplicationType - || msg.getNotifier() instanceof FactoryType - || msg.getNotifier() instanceof LifecycleType) { - - if (msg.getEventType() == Notification.ADD) { - EObject newObject = (EObject) msg.getNewValue(); - if (newObject != null) { - addOverviewOthersSectionAdapter(newObject); - } - } - - if (msg.getEventType() == Notification.ADD - || msg.getEventType() == Notification.REMOVE - || msg.getEventType() == Notification.SET) { - refreshAll(); - } - } - - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/PropertySection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/PropertySection.java deleted file mode 100644 index fdabeb1a1..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/PropertySection.java +++ /dev/null @@ -1,501 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.section; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.Assert; -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.common.command.CompoundCommand; -import org.eclipse.emf.edit.command.AddCommand; -import org.eclipse.emf.edit.command.RemoveCommand; -import org.eclipse.emf.edit.command.SetCommand; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jst.jsf.facesconfig.emf.DefaultValueType; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.emf.PropertyClassType; -import org.eclipse.jst.jsf.facesconfig.emf.PropertyNameType; -import org.eclipse.jst.jsf.facesconfig.emf.PropertyType; -import org.eclipse.jst.jsf.facesconfig.emf.SuggestedValueType; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.jst.jsf.facesconfig.ui.dialog.AddEditPropertyDialog; -import org.eclipse.jst.jsf.facesconfig.ui.page.IFacesConfigPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.MouseAdapter; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.widgets.FormToolkit; - -public class PropertySection extends AbstractFacesConfigSection { - - private static final int TABLE_DEFAULT_HEIGHT = 160; - - private TableViewer tableViewer; - - private Button removeButton; - - private Button editButton; - - /** - * - * @param parent - * @param managedForm - * @param page - * @param toolkit - */ - public PropertySection(Composite parent, IManagedForm managedForm, - IFacesConfigPage page, FormToolkit toolkit) { - super(parent, managedForm, page, toolkit, null, null); - this.getSection().setText(EditorMessages.PropertySection_Name); - this.getSection().setDescription( - EditorMessages.PropertySection_Description); - - } - - /** - * @param container - * @param toolkit - */ - protected void createContents(Composite container, FormToolkit toolkit) { - GridLayout gl = new GridLayout(); - gl.horizontalSpacing = 0; - gl.marginWidth = 0; - gl.numColumns = 2; - container.setLayout(gl); - GridData td = new GridData(GridData.FILL_BOTH); - container.setLayoutData(td); - - toolkit.paintBordersFor(container); - - Composite propertySection = toolkit.createComposite(container); - GridLayout gl2 = new GridLayout(); - gl2.horizontalSpacing = 0; - gl2.verticalSpacing = 0; - gl2.marginWidth = 0; - gl2.marginHeight = 0; - gl2.numColumns = 2; - propertySection.setLayout(gl2); - GridData gd = new GridData(GridData.FILL_BOTH - | GridData.VERTICAL_ALIGN_BEGINNING); - propertySection.setLayoutData(gd); - - createTableSection(propertySection, toolkit); - createButtonsSection(propertySection, toolkit); - - } - - /** - * create table section - * - * @param container - * @param toolkit - */ - private void createTableSection(Composite container, FormToolkit toolkit) { - Composite tableContainer = toolkit.createComposite(container); - GridData gd = new GridData(GridData.FILL_BOTH - | GridData.GRAB_HORIZONTAL); - tableContainer.setLayoutData(gd); - toolkit.paintBordersFor(tableContainer); - - GridLayout gl = new GridLayout(); - tableContainer.setLayout(gl); - - Table table = new Table(tableContainer, SWT.H_SCROLL | SWT.V_SCROLL - | SWT.FULL_SELECTION | SWT.BORDER); - gd = new GridData(GridData.FILL_BOTH); - gd.horizontalSpan = 1; - gd.heightHint = TABLE_DEFAULT_HEIGHT; - table.setLayoutData(gd); - - table.setHeaderVisible(true); - table.setLinesVisible(true); - TableLayout layout = new TableLayout(); - table.setLayout(layout); - - TableColumn nameCol = new TableColumn(table, SWT.NONE); - layout.addColumnData(new ColumnWeightData(1, true)); - nameCol.setText(EditorMessages.PropertySection_Table_NameColumn);//$NON-NLS-1$ - - TableColumn classCol = new TableColumn(table, SWT.NONE); - layout.addColumnData(new ColumnWeightData(1, true)); - classCol - .setText(EditorMessages.PropertySection_Table_ClassColumn); - - TableColumn valueCol = new TableColumn(table, SWT.NONE); - layout.addColumnData(new ColumnWeightData(1, true)); - valueCol - .setText(EditorMessages.PropertySection_Table_DefaultValueColumn); - - TableColumn suggestedValueCol = new TableColumn(table, SWT.NONE); - layout.addColumnData(new ColumnWeightData(1, true)); - suggestedValueCol - .setText(EditorMessages.PropertySection_Table_SuggestedValueColumn); - - table.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - updateButtons(); - } - }); - - table.addMouseListener(new MouseAdapter() { - public void mouseDoubleClick(MouseEvent e) { - if (((IStructuredSelection) tableViewer.getSelection()).size() > 0) - editButtonSelected(); - } - }); - - tableViewer = new TableViewer(table); - tableViewer.setContentProvider(new AdapterFactoryContentProvider( - getAdapterFactory())); - tableViewer.setLabelProvider(new AdapterFactoryLabelProvider( - getAdapterFactory())); - - tableViewer.addFilter(new ViewerFilter() { - public boolean select(Viewer viewer, Object parentElement, - Object element) { - return FacesConfigPackage.eINSTANCE.getPropertyType() - .isInstance(element); - } - }); - tableViewer.addSelectionChangedListener(this); - } - - /** - * Update the buttons' enable and disable status - */ - private void updateButtons() { - if (((IStructuredSelection) tableViewer.getSelection()).size() > 0) { - editButton.setEnabled(true); - removeButton.setEnabled(true); - } else { - editButton.setEnabled(false); - removeButton.setEnabled(false); - } - } - - /** - * create property's editing buttons - * - * @param container - * @param toolkit - */ - private void createButtonsSection(Composite container, FormToolkit toolkit) { - // create operation buttons's container - Composite operationContainer = toolkit.createComposite(container); - GridData gd = new GridData(GridData.FILL_VERTICAL - | GridData.VERTICAL_ALIGN_BEGINNING); - operationContainer.setLayoutData(gd); - GridLayout gl = new GridLayout(); - operationContainer.setLayout(gl); - - Button addButton = toolkit.createButton(operationContainer, - EditorMessages.UI_Button_Add_more, //$NON-NLS-1$ - SWT.PUSH); - gd = new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING); - gd.grabExcessHorizontalSpace = false; - addButton.setLayoutData(gd); - - editButton = toolkit.createButton(operationContainer, - EditorMessages.UI_Button_Edit_more, //$NON-NLS-1$ - SWT.PUSH); - gd = new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING); - gd.grabExcessHorizontalSpace = false; - editButton.setLayoutData(gd); - - removeButton = toolkit.createButton(operationContainer, - EditorMessages.UI_Button_Remove, //$NON-NLS-1$ - SWT.PUSH); - gd = new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING); - gd.grabExcessHorizontalSpace = false; - removeButton.setLayoutData(gd); - - addButton.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent e) { - addButtonSelected(); - } - - }); - - editButton.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent e) { - editButtonSelected(); - } - - }); - removeButton.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent e) { - removeButtonSelected(); - } - - }); - } - - /** - * refresh the table viewer and update buttons. - */ - public void refresh() { - super.refresh(); - tableViewer.refresh(); - updateButtons(); - } - - /** - * - */ - public void refreshAll() { - tableViewer.setInput(getInput()); - updateButtons(); - - } - - /** - * add a property. - * - */ - private void addButtonSelected() { - - Shell shell = EditorPlugin.getActiveShell(); - - AddEditPropertyDialog dialog = new AddEditPropertyDialog(shell, true); - dialog.setProject((IProject) getPage().getEditor().getAdapter( - IProject.class)); - if (dialog.open() == Dialog.OK) { - - PropertyType newProperty = FacesConfigFactory.eINSTANCE - .createPropertyType(); - - if (dialog.getPropertyName().length() > 0) { - PropertyNameType propertyNameType = FacesConfigFactory.eINSTANCE - .createPropertyNameType(); - propertyNameType.setTextContent(dialog.getPropertyName()); - newProperty.setPropertyName(propertyNameType); - } - - if (dialog.getPropertyClass().length() > 0) { - PropertyClassType propertyClassType = FacesConfigFactory.eINSTANCE - .createPropertyClassType(); - propertyClassType.setTextContent(dialog.getPropertyClass()); - newProperty.setPropertyClass(propertyClassType); - } - - if (dialog.getDefaultValue().length() > 0) { - DefaultValueType defaultValueType = FacesConfigFactory.eINSTANCE - .createDefaultValueType(); - defaultValueType.setTextContent(dialog.getDefaultValue()); - newProperty.setDefaultValue(defaultValueType); - } - - if (dialog.getSuggestedValue().length() > 0) { - SuggestedValueType suggestedValueType = FacesConfigFactory.eINSTANCE - .createSuggestedValueType(); - suggestedValueType.setTextContent(dialog.getSuggestedValue()); - newProperty.setSuggestedValue(suggestedValueType); - } - - Command addCommand = AddCommand.create(this.getEditingDomain(), - getInput(), null, newProperty); - if (addCommand.canExecute()) { - this.getEditingDomain().getCommandStack().execute(addCommand); - - } - } - - } - - /** - * edit a property. - * - */ - private void editButtonSelected() { - - PropertyType property = (PropertyType) ((IStructuredSelection) tableViewer - .getSelection()).getFirstElement(); - - Assert.isNotNull(property); - - Shell shell = EditorPlugin.getActiveShell(); - - AddEditPropertyDialog dialog = new AddEditPropertyDialog(shell, false); - dialog.setProject((IProject) getPage().getEditor().getAdapter( - IProject.class)); - if (property.getPropertyName() != null) { - dialog.setPropertyName(property.getPropertyName().getTextContent()); - } - - if (property.getPropertyClass() != null) { - dialog.setPropertyClass(property.getPropertyClass() - .getTextContent()); - } - - if (property.getDefaultValue() != null) { - dialog.setDefaultValue(property.getDefaultValue().getTextContent()); - } - - if (property.getSuggestedValue() != null) { - dialog.setSuggestedValue(property.getSuggestedValue() - .getTextContent()); - } - - if (dialog.open() == Dialog.OK) { - List commands = new ArrayList(4); - - if (property.getPropertyName() != null) { - Command cmd1 = SetCommand.create(this.getEditingDomain(), - property.getPropertyName(), - FacesConfigPackage.eINSTANCE - .getPropertyNameType_TextContent(), dialog - .getPropertyName()); - commands.add(cmd1); - } else if (dialog.getPropertyName().length() > 0) { - PropertyNameType propertyNameType = FacesConfigFactory.eINSTANCE - .createPropertyNameType(); - propertyNameType.setTextContent(dialog.getPropertyName()); - - Command cmd2 = AddCommand.create(this.getEditingDomain(), - property, FacesConfigPackage.eINSTANCE - .getPropertyType_PropertyName(), - propertyNameType); - commands.add(cmd2); - } - - if (property.getPropertyClass() != null) { - Command cmd3 = SetCommand.create(this.getEditingDomain(), - property.getPropertyClass(), - FacesConfigPackage.eINSTANCE - .getPropertyClassType_TextContent(), dialog - .getPropertyClass()); - commands.add(cmd3); - } else if (dialog.getPropertyClass().length() > 0) { - PropertyClassType propertyClassType = FacesConfigFactory.eINSTANCE - .createPropertyClassType(); - propertyClassType.setTextContent(dialog.getPropertyClass()); - - Command cmd4 = AddCommand.create(this.getEditingDomain(), - property, FacesConfigPackage.eINSTANCE - .getPropertyType_PropertyClass(), - propertyClassType); - commands.add(cmd4); - } - - if (property.getDefaultValue() != null) { - Command cmd5 = SetCommand.create(this.getEditingDomain(), - property.getDefaultValue(), - FacesConfigPackage.eINSTANCE - .getDefaultValueType_TextContent(), dialog - .getDefaultValue()); - commands.add(cmd5); - - } else if (dialog.getDefaultValue().length() > 0) { - DefaultValueType defaultValueType = FacesConfigFactory.eINSTANCE - .createDefaultValueType(); - defaultValueType.setTextContent(dialog.getDefaultValue()); - Command cmd6 = AddCommand.create(this.getEditingDomain(), - property, FacesConfigPackage.eINSTANCE - .getPropertyType_DefaultValue(), - defaultValueType); - commands.add(cmd6); - } - - if (property.getSuggestedValue() != null) { - Command cmd7 = SetCommand.create(this.getEditingDomain(), - property.getSuggestedValue(), - FacesConfigPackage.eINSTANCE - .getSuggestedValueType_TextContent(), dialog - .getSuggestedValue()); - commands.add(cmd7); - } else if (dialog.getSuggestedValue().length() > 0) { - SuggestedValueType suggestedValueType = FacesConfigFactory.eINSTANCE - .createSuggestedValueType(); - suggestedValueType.setTextContent(dialog.getSuggestedValue()); - Command cmd8 = AddCommand.create(this.getEditingDomain(), - property, FacesConfigPackage.eINSTANCE - .getPropertyType_SuggestedValue(), - suggestedValueType); - commands.add(cmd8); - } - - CompoundCommand command = new CompoundCommand(commands); - if (command.canExecute()) { - this.getEditingDomain().getCommandStack().execute(command); - tableViewer.refresh(property); - - } - } - - } - - /** - * remove a property. - * - */ - private void removeButtonSelected() { - PropertyType property = (PropertyType) ((IStructuredSelection) tableViewer - .getSelection()).getFirstElement(); - - Assert.isNotNull(property); - - Command removeCommand = RemoveCommand.create(this.getEditingDomain(), - getInput(), null, property); - - if (removeCommand.canExecute()) { - this.getEditingDomain().getCommandStack().execute(removeCommand); - refreshAll(); - } - - } - - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection() - */ - public ISelection getSelection() { - return tableViewer.getSelection(); - } - - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection) - */ - public void setSelection(ISelection selection) { - - tableViewer.setSelection(selection); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/RendererSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/RendererSection.java deleted file mode 100644 index ea1b71979..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/RendererSection.java +++ /dev/null @@ -1,531 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.section; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.Assert; -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.common.command.CompoundCommand; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EReference; -import org.eclipse.emf.edit.command.AddCommand; -import org.eclipse.emf.edit.command.RemoveCommand; -import org.eclipse.emf.edit.command.SetCommand; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; -import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jst.jsf.facesconfig.emf.ComponentFamilyType; -import org.eclipse.jst.jsf.facesconfig.emf.DisplayNameType; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.emf.RenderKitType; -import org.eclipse.jst.jsf.facesconfig.emf.RendererClassType; -import org.eclipse.jst.jsf.facesconfig.emf.RendererType; -import org.eclipse.jst.jsf.facesconfig.emf.RendererTypeType; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.jst.jsf.facesconfig.ui.dialog.AddEditRendererDialog; -import org.eclipse.jst.jsf.facesconfig.ui.page.IFacesConfigPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.MouseAdapter; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * @author Bryan Yang - * - */ -public class RendererSection extends AbstractFacesConfigSection { - - private static final int TABLE_DEFAULT_HEIGHT = 160; - - private TableViewer tableViewer; - - private Button removeButton; - - private Button editButton; - - /** - * - * @param parent - * @param managedForm - * @param page - * @param toolkit - */ - public RendererSection(Composite parent, IManagedForm managedForm, - IFacesConfigPage page, FormToolkit toolkit) { - super(parent, managedForm, page, toolkit, null, null); - this.getSection().setText(EditorMessages.RendererSection_Name); - this.getSection().setDescription( - EditorMessages.RendererSection_Description); - - } - - /** - * - */ - protected void createContents(Composite container, FormToolkit toolkit) { - GridLayout gl = new GridLayout(); - gl.horizontalSpacing = 0; - gl.marginWidth = 0; - gl.numColumns = 2; - container.setLayout(gl); - GridData td = new GridData(GridData.FILL_BOTH); - container.setLayoutData(td); - - toolkit.paintBordersFor(container); - - Composite RendererSection = toolkit.createComposite(container); - GridLayout gl2 = new GridLayout(); - gl2.horizontalSpacing = 0; - gl2.verticalSpacing = 0; - gl2.marginWidth = 0; - gl2.marginHeight = 0; - gl2.numColumns = 2; - RendererSection.setLayout(gl2); - GridData gd = new GridData(GridData.FILL_BOTH - | GridData.VERTICAL_ALIGN_BEGINNING); - RendererSection.setLayoutData(gd); - - createTableSection(RendererSection, toolkit); - createButtonsSection(RendererSection, toolkit); - - } - - /** - * create table section - * - * @param container - * @param toolkit - */ - private void createTableSection(Composite container, FormToolkit toolkit) { - Composite tableContainer = toolkit.createComposite(container); - GridData gd = new GridData(GridData.FILL_BOTH - | GridData.GRAB_HORIZONTAL); - tableContainer.setLayoutData(gd); - toolkit.paintBordersFor(tableContainer); - - GridLayout gl = new GridLayout(); - tableContainer.setLayout(gl); - - Table table = new Table(tableContainer, SWT.H_SCROLL | SWT.V_SCROLL - | SWT.FULL_SELECTION | SWT.BORDER); - gd = new GridData(GridData.FILL_BOTH); - gd.horizontalSpan = 1; - gd.heightHint = TABLE_DEFAULT_HEIGHT; - table.setLayoutData(gd); - - table.setHeaderVisible(true); - table.setLinesVisible(true); - TableLayout layout = new TableLayout(); - table.setLayout(layout); - - TableColumn nameCol = new TableColumn(table, SWT.NONE); - layout.addColumnData(new ColumnWeightData(1, true)); - nameCol.setText(EditorMessages.RendererSection_Table_NameColumn); - - TableColumn valueCol = new TableColumn(table, SWT.NONE); - layout.addColumnData(new ColumnWeightData(1, true)); - valueCol - .setText(EditorMessages.RendererSection_Table_ComponentFamilyColumn); - - TableColumn suggestedValueCol = new TableColumn(table, SWT.NONE); - layout.addColumnData(new ColumnWeightData(1, true)); - suggestedValueCol - .setText(EditorMessages.RendererSection_Table_TypeColumn); - - TableColumn classCol = new TableColumn(table, SWT.NONE); - layout.addColumnData(new ColumnWeightData(1, true)); - classCol.setText(EditorMessages.RendererSection_Table_ClassColumn); - - table.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - updateButtons(); - } - }); - - table.addMouseListener(new MouseAdapter() { - public void mouseDoubleClick(MouseEvent e) { - if (((IStructuredSelection) tableViewer.getSelection()).size() > 0) - editButtonSelected(); - } - }); - - tableViewer = new TableViewer(table); - tableViewer.setContentProvider(new AdapterFactoryContentProvider( - getAdapterFactory())); - tableViewer.setLabelProvider(new AdapterFactoryLabelProvider( - getAdapterFactory())); - - tableViewer.addFilter(new ViewerFilter() { - public boolean select(Viewer viewer, Object parentElement, - Object element) { - return FacesConfigPackage.eINSTANCE.getRendererType() - .isInstance(element); - } - }); - - tableViewer.addSelectionChangedListener(this); - } - - /** - * Update the buttons' enable and disable status - */ - private void updateButtons() { - if (((IStructuredSelection) tableViewer.getSelection()).size() > 0) { - editButton.setEnabled(true); - removeButton.setEnabled(true); - } else { - editButton.setEnabled(false); - removeButton.setEnabled(false); - } - } - - /** - * create buttons - * - * @param container - * @param toolkit - */ - private void createButtonsSection(Composite container, FormToolkit toolkit) { - // create operation buttons's container - Composite operationContainer = toolkit.createComposite(container); - GridData gd = new GridData(GridData.FILL_VERTICAL - | GridData.VERTICAL_ALIGN_BEGINNING); - operationContainer.setLayoutData(gd); - GridLayout gl = new GridLayout(); - operationContainer.setLayout(gl); - - Button addButton = toolkit.createButton(operationContainer, - EditorMessages.UI_Button_Add_more, //$NON-NLS-1$ - SWT.PUSH); - gd = new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING); - gd.grabExcessHorizontalSpace = false; - addButton.setLayoutData(gd); - - editButton = toolkit.createButton(operationContainer, - EditorMessages.UI_Button_Edit_more, //$NON-NLS-1$ - SWT.PUSH); - gd = new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING); - gd.grabExcessHorizontalSpace = false; - editButton.setLayoutData(gd); - - removeButton = toolkit.createButton(operationContainer, - EditorMessages.UI_Button_Remove, //$NON-NLS-1$ - SWT.PUSH); - gd = new GridData(GridData.FILL_HORIZONTAL - | GridData.VERTICAL_ALIGN_BEGINNING); - gd.grabExcessHorizontalSpace = false; - removeButton.setLayoutData(gd); - - addButton.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent e) { - addButtonSelected(); - } - - }); - - editButton.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent e) { - editButtonSelected(); - } - - }); - removeButton.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent e) { - removeButtonSelected(); - } - - }); - } - - /** - * - * @return - */ - private EReference getEReference() { - EReference reference = null; - if (getInput() instanceof RenderKitType) { - reference = FacesConfigPackage.eINSTANCE - .getRenderKitType_Renderer(); - } - return reference; - } - - - /** - * - */ - public void refreshAll() { - tableViewer.setInput(getInput()); - updateButtons(); - - } - - /** - * - */ - public void refresh() { - super.refresh(); - tableViewer.refresh(); - updateButtons(); - } - - /** - * add an Renderer. - * - */ - private void addButtonSelected() { - Shell shell = EditorPlugin.getActiveShell(); - - AddEditRendererDialog dialog = new AddEditRendererDialog(shell, this - .getPage(), true); - dialog.setProject((IProject) getPage().getEditor().getAdapter( - IProject.class)); - if (dialog.open() == Dialog.OK) { - - // RendererType newRenderer = dialog.getResult(); - RendererType newRenderer = FacesConfigFactory.eINSTANCE - .createRendererType(); - - if (dialog.getRendererName().length() > 0) { - DisplayNameType diaplayName = FacesConfigFactory.eINSTANCE - .createDisplayNameType(); - diaplayName.setTextContent(dialog.getRendererName()); - newRenderer.getDisplayName().add(diaplayName); - } - - if (dialog.getRendererClass().length() > 0) { - RendererClassType RendererClassType = FacesConfigFactory.eINSTANCE - .createRendererClassType(); - RendererClassType.setTextContent(dialog.getRendererClass()); - newRenderer.setRendererClass(RendererClassType); - } - - if (dialog.getComponentFamily().length() > 0) { - ComponentFamilyType componentFamilyType = FacesConfigFactory.eINSTANCE - .createComponentFamilyType(); - componentFamilyType.setTextContent(dialog.getComponentFamily()); - newRenderer.setComponentFamily(componentFamilyType); - } - - if (dialog.getRendererType().length() > 0) { - RendererTypeType rendererType = FacesConfigFactory.eINSTANCE - .createRendererTypeType(); - rendererType.setTextContent(dialog.getRendererType()); - newRenderer.setRendererType(rendererType); - } - - Command addCommand = AddCommand.create(this.getEditingDomain(), - getInput(), getEReference(), newRenderer); - if (addCommand.canExecute()) { - this.getEditingDomain().getCommandStack().execute(addCommand); - - } - } - - } - - /** - * edit an Renderer. - * - */ - private void editButtonSelected() { - - RendererType renderer = (RendererType) ((IStructuredSelection) tableViewer - .getSelection()).getFirstElement(); - - Assert.isNotNull(renderer); - - Shell shell = EditorPlugin.getActiveShell(); - - AddEditRendererDialog dialog = new AddEditRendererDialog(shell, this - .getPage(), false); - dialog.setProject((IProject) getPage().getEditor().getAdapter( - IProject.class)); - if (renderer.getDisplayName() != null - && renderer.getDisplayName().size() > 0) { - String name = ((DisplayNameType) (renderer.getDisplayName().get(0))) - .getTextContent(); - if (name == null) { - name = ""; - } - dialog.setRendererName(name); - } - - if (renderer.getRendererClass() != null) { - dialog.setRendererClass(renderer.getRendererClass() - .getTextContent()); - } - - if (renderer.getComponentFamily() != null) { - dialog.setComponentFamily(renderer.getComponentFamily() - .getTextContent()); - } - - if (renderer.getRendererType() != null) { - dialog.setRendererType(renderer.getRendererType().getTextContent()); - } - - if (dialog.open() == Dialog.OK) { - List commands = new ArrayList(4); - - if (renderer.getDisplayName() != null - && renderer.getDisplayName().size() > 0) { - DisplayNameType diaplayName = FacesConfigFactory.eINSTANCE - .createDisplayNameType(); - diaplayName.setTextContent(dialog.getRendererName()); - - Command cmd1 = SetCommand.create(this.getEditingDomain(), - renderer.getDisplayName().get(0), - FacesConfigPackage.eINSTANCE - .getRendererType_DisplayName(), diaplayName); - commands.add(cmd1); - } else if (dialog.getRendererName().length() > 0) { - DisplayNameType displayName = FacesConfigFactory.eINSTANCE - .createDisplayNameType(); - displayName.setTextContent(dialog.getRendererName()); - - EList dl = renderer.getDisplayName(); - dl.add(displayName); - Command cmd2 = AddCommand.create(this.getEditingDomain(), - renderer.getDisplayName(), FacesConfigPackage.eINSTANCE - .getRendererType_DisplayName(), dl); - commands.add(cmd2); - } - - if (renderer.getRendererClass() != null) { - Command cmd3 = SetCommand.create(this.getEditingDomain(), - renderer.getRendererClass(), - FacesConfigPackage.eINSTANCE - .getRendererClassType_TextContent(), dialog - .getRendererClass()); - commands.add(cmd3); - } else if (dialog.getRendererClass().length() > 0) { - RendererClassType RendererClassType = FacesConfigFactory.eINSTANCE - .createRendererClassType(); - RendererClassType.setTextContent(dialog.getRendererClass()); - - Command cmd4 = AddCommand.create(this.getEditingDomain(), - renderer, FacesConfigPackage.eINSTANCE - .getRendererType_RendererClass(), - RendererClassType); - commands.add(cmd4); - } - - if (renderer.getComponentFamily() != null) { - Command cmd5 = SetCommand.create(this.getEditingDomain(), - renderer.getComponentFamily(), - FacesConfigPackage.eINSTANCE - .getDefaultValueType_TextContent(), dialog - .getComponentFamily()); - commands.add(cmd5); - - } else if (dialog.getComponentFamily().length() > 0) { - ComponentFamilyType componentFamily = FacesConfigFactory.eINSTANCE - .createComponentFamilyType(); - componentFamily.setTextContent(dialog.getComponentFamily()); - Command cmd6 = AddCommand.create(this.getEditingDomain(), - renderer, FacesConfigPackage.eINSTANCE - .getRendererType_ComponentFamily(), - componentFamily); - commands.add(cmd6); - } - - if (renderer.getRendererType() != null) { - Command cmd7 = SetCommand.create(this.getEditingDomain(), - renderer.getRendererType(), - FacesConfigPackage.eINSTANCE - .getSuggestedValueType_TextContent(), dialog - .getRendererType()); - commands.add(cmd7); - } else if (dialog.getRendererType().length() > 0) { - RendererTypeType rendererType = FacesConfigFactory.eINSTANCE - .createRendererTypeType(); - rendererType.setTextContent(dialog.getRendererType()); - Command cmd8 = AddCommand.create(this.getEditingDomain(), - renderer, FacesConfigPackage.eINSTANCE - .getRendererType_RendererType(), rendererType); - commands.add(cmd8); - } - - CompoundCommand command = new CompoundCommand(commands); - if (command.canExecute()) { - this.getEditingDomain().getCommandStack().execute(command); - tableViewer.refresh(renderer); - - } - } - - } - - /** - * remove an Renderer. - * - */ - private void removeButtonSelected() { - RendererType Renderer = (RendererType) ((IStructuredSelection) tableViewer - .getSelection()).getFirstElement(); - - Assert.isNotNull(Renderer); - - Command removeCommand = RemoveCommand.create(this.getEditingDomain(), - getInput(), getEReference(), Renderer); - - if (removeCommand.canExecute()) { - this.getEditingDomain().getCommandStack().execute(removeCommand); - refreshAll(); - } - - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection() - */ - public ISelection getSelection() { - return tableViewer.getSelection(); - } - - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection) - */ - public void setSelection(ISelection selection) { - - tableViewer.setSelection(selection); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/RenderkitGeneralSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/RenderkitGeneralSection.java deleted file mode 100644 index 399f547aa..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/RenderkitGeneralSection.java +++ /dev/null @@ -1,399 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.section; - -import org.eclipse.core.resources.IProject; -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.impl.AdapterImpl; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.emf.edit.command.AddCommand; -import org.eclipse.emf.edit.command.SetCommand; -import org.eclipse.emf.edit.domain.EditingDomain; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.ClassButtonDialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.IDialogFieldApplyListener; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.LayoutUtil; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.StringDialogField; -import org.eclipse.jst.jsf.facesconfig.emf.DescriptionType; -import org.eclipse.jst.jsf.facesconfig.emf.DisplayNameType; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.emf.RenderKitClassType; -import org.eclipse.jst.jsf.facesconfig.emf.RenderKitIdType; -import org.eclipse.jst.jsf.facesconfig.emf.RenderKitType; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.jst.jsf.facesconfig.ui.IFacesConfigConstants; -import org.eclipse.jst.jsf.facesconfig.ui.page.IFacesConfigPage; -import org.eclipse.jst.jsf.facesconfig.ui.util.ModelUtil; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * @author Bryan Yang - * - */ -public class RenderkitGeneralSection extends AbstractFacesConfigSection { - - private StringDialogField displayNameField; - - private StringDialogField descriptionField; - - private StringDialogField renderkitIdField; - - private ClassButtonDialogField renderkitClassField; - - private RenderKitGeneralAdapter renderKitGeneralAdapter; - - /** - * - * @param parent - * @param managedForm - * @param page - * @param toolkit - */ - public RenderkitGeneralSection(Composite parent, IManagedForm managedForm, - IFacesConfigPage page, FormToolkit toolkit) { - super(parent, managedForm, page, toolkit, null, null); - getSection() - .setText(EditorMessages.RenderKitGeneralSection_Name); - getSection().setDescription( - EditorMessages.RenderKitGeneralSection_Description); - } - - /** - * - */ - protected void createContents(Composite container, FormToolkit toolkit) { - int numberOfColumns = 4; - GridLayout layout = new GridLayout(numberOfColumns, false); - container.setLayout(layout); - GridData td = new GridData(GridData.FILL_HORIZONTAL); - container.setLayoutData(td); - - toolkit.paintBordersFor(container); - displayNameField = new StringDialogField(); - displayNameField - .setLabelText(EditorMessages.RenderKitGeneralSection_Label_DisplayName); - displayNameField.doFillIntoGrid(toolkit, container, numberOfColumns); - - displayNameField - .setDialogFieldApplyListener(new IDialogFieldApplyListener() { - - public void dialogFieldApplied(DialogField field) { - String newDisplayNameValue = ((StringDialogField) field) - .getText().trim(); - Command cmd = null; - RenderKitType Renderkit = (RenderKitType) getInput(); - EditingDomain editingDomain = getEditingDomain(); - if (Renderkit.getDisplayName().size() > 0) { - DisplayNameType displayName = (DisplayNameType) Renderkit - .getDisplayName().get(0); - cmd = SetCommand.create(editingDomain, displayName, - FacesConfigPackage.eINSTANCE - .getDisplayNameType_TextContent(), - newDisplayNameValue); - } else { - DisplayNameType displayNameType = FacesConfigFactory.eINSTANCE - .createDisplayNameType(); - displayNameType.setTextContent(newDisplayNameValue); - displayNameType.eAdapters().add( - getRenderKitGeneralAdapter()); - - cmd = AddCommand.create(editingDomain, Renderkit, - FacesConfigPackage.eINSTANCE - .getRenderKitType_DisplayName(), - displayNameType); - } - if (cmd.canExecute()) { - editingDomain.getCommandStack().execute(cmd); - } - } - - }); - - descriptionField = new StringDialogField(2); - descriptionField - .setLabelText(EditorMessages.RenderKitGeneralSection_Label_Description); - descriptionField.doFillIntoGrid(toolkit, container, numberOfColumns); - - descriptionField - .setDialogFieldApplyListener(new IDialogFieldApplyListener() { - public void dialogFieldApplied(DialogField field) { - String newDescriptionValue = ((StringDialogField) field) - .getText().trim(); - newDescriptionValue = ModelUtil - .escapeEntities(newDescriptionValue); - Command cmd = null; - RenderKitType Renderkit = (RenderKitType) getInput(); - EditingDomain editingDomain = getEditingDomain(); - if (Renderkit.getDescription().size() > 0) { - DescriptionType description = (DescriptionType) Renderkit - .getDescription().get(0); - cmd = SetCommand.create(editingDomain, description, - FacesConfigPackage.eINSTANCE - .getDescriptionType_TextContent(), - newDescriptionValue); - } else { - DescriptionType description = FacesConfigFactory.eINSTANCE - .createDescriptionType(); - description.setTextContent(newDescriptionValue); - description.eAdapters().add( - getRenderKitGeneralAdapter()); - - cmd = AddCommand.create(editingDomain, Renderkit, - FacesConfigPackage.eINSTANCE - .getRenderKitType_Description(), - description); - } - if (cmd.canExecute()) { - editingDomain.getCommandStack().execute(cmd); - } - } - }); - - renderkitIdField = new StringDialogField(); - // renderkitIdField.setRequired(true); - renderkitIdField - .setLabelText(EditorMessages.RenderKitGeneralSection_Label_RenderKitID); - renderkitIdField.doFillIntoGrid(toolkit, container, numberOfColumns); - renderkitIdField - .setDialogFieldApplyListener(new IDialogFieldApplyListener() { - public void dialogFieldApplied(DialogField field) { - RenderKitIdType RenderkitId = FacesConfigFactory.eINSTANCE - .createRenderKitIdType(); - RenderkitId.setTextContent(((StringDialogField) field) - .getText()); - - EditingDomain editingDomain = getEditingDomain(); - if (editingDomain != null) { - Command command = SetCommand.create(editingDomain, - getInput(), FacesConfigPackage.eINSTANCE - .getRenderKitType_RenderKitId(), - RenderkitId); - if (command.canExecute()) { - editingDomain.getCommandStack() - .execute(command); - } - } - } - }); - - renderkitClassField = new ClassButtonDialogField(null); - // renderkitClassField.setRequired(true); - renderkitClassField - .setLabelText(EditorMessages.RenderKitGeneralSection_Label_RenderKitClass); - renderkitClassField.doFillIntoGrid(toolkit, container, numberOfColumns); - renderkitClassField.setProject((IProject) getPage().getEditor() - .getAdapter(IProject.class)); - LayoutUtil.setHorizontalGrabbing(renderkitClassField.getTextControl( - toolkit, container)); - - renderkitClassField - .setDialogFieldApplyListener(new IDialogFieldApplyListener() { - public void dialogFieldApplied(DialogField field) { - - RenderKitClassType RenderkitClass = FacesConfigFactory.eINSTANCE - .createRenderKitClassType(); - RenderkitClass - .setTextContent(((StringDialogField) field) - .getText()); - EditingDomain editingDomain = getEditingDomain(); - if (editingDomain != null) { - Command command = SetCommand.create(editingDomain, - getInput(), FacesConfigPackage.eINSTANCE - .getRenderKitType_RenderKitClass(), - RenderkitClass); - if (command.canExecute()) { - editingDomain.getCommandStack() - .execute(command); - } - } - - } - }); - renderkitClassField - .setSuperClassName(IFacesConfigConstants.RENDER_KIT_SUPER_CLASS); - } - - /** - * - */ - public void refreshAll() { - refresh(); - } - - /** - * - */ - public void refresh() { - super.refresh(); - Object input = this.getInput(); - if (input instanceof RenderKitType) { - RenderKitType Renderkit = (RenderKitType) input; - - if (Renderkit.getDisplayName().size() > 0) { - DisplayNameType displayName = (DisplayNameType) Renderkit - .getDisplayName().get(0); - displayNameField.setTextWithoutUpdate(displayName - .getTextContent()); - } else { - displayNameField.setTextWithoutUpdate(""); - } - - if (Renderkit.getDescription().size() > 0) { - DescriptionType description = (DescriptionType) Renderkit - .getDescription().get(0); - String descriptionString = description.getTextContent(); - descriptionString = ModelUtil - .unEscapeEntities(descriptionString); - descriptionField.setTextWithoutUpdate(descriptionString); - } else { - descriptionField.setTextWithoutUpdate(""); - } - - if (Renderkit.getRenderKitId() != null) { - renderkitIdField.setTextWithoutUpdate(Renderkit - .getRenderKitId().getTextContent()); - } else { - renderkitIdField.setTextWithoutUpdate(""); - } - - if (Renderkit.getRenderKitClass() != null) { - renderkitClassField.setTextWithoutUpdate(Renderkit - .getRenderKitClass().getTextContent()); - } else { - renderkitClassField.setTextWithoutUpdate(""); - } - } - } - - /** - * Add RenderKitGeneralAdapter onto <render-kit> and the first - * <display-name> and <description> elements. - */ - protected void addAdaptersOntoInput(Object newInput) { - RenderKitType renderkit = (RenderKitType) newInput; - if (EcoreUtil.getExistingAdapter(renderkit, - RenderkitGeneralSection.class) == null) { - - renderkit.eAdapters().add(getRenderKitGeneralAdapter()); - } - - if (renderkit.getDisplayName().size() > 0) { - DisplayNameType displayName = (DisplayNameType) renderkit - .getDisplayName().get(0); - if (EcoreUtil.getExistingAdapter(displayName, - RenderkitGeneralSection.class) == null) { - - displayName.eAdapters().add(getRenderKitGeneralAdapter()); - } - } - - if (renderkit.getDescription().size() > 0) { - DescriptionType description = (DescriptionType) renderkit - .getDescription().get(0); - if (EcoreUtil.getExistingAdapter(description, - RenderkitGeneralSection.class) == null) { - - description.eAdapters().add(getRenderKitGeneralAdapter()); - } - } - } - - /** - * Remove RenderKitGeneralAdapter from <render-kit> and the first - * <display-name> and <description> elements. - */ - protected void removeAdaptersFromInput(Object oldInput) { - RenderKitType renderkit = (RenderKitType) oldInput; - if (EcoreUtil.getExistingAdapter(renderkit, - RenderkitGeneralSection.class) != null) { - renderkit.eAdapters().remove(getRenderKitGeneralAdapter()); - } - if (renderkit.getDisplayName().size() > 0) { - DisplayNameType displayName = (DisplayNameType) renderkit - .getDisplayName().get(0); - if (EcoreUtil.getExistingAdapter(displayName, - RenderkitGeneralSection.class) != null) { - - displayName.eAdapters().remove(getRenderKitGeneralAdapter()); - } - } - - if (renderkit.getDescription().size() > 0) { - DescriptionType description = (DescriptionType) renderkit - .getDescription().get(0); - if (EcoreUtil.getExistingAdapter(description, - RenderkitGeneralSection.class) != null) { - - description.eAdapters().remove(getRenderKitGeneralAdapter()); - } - } - } - - /** - * - * @return - */ - private Adapter getRenderKitGeneralAdapter() { - - if (renderKitGeneralAdapter == null) { - renderKitGeneralAdapter = new RenderKitGeneralAdapter(); - } - return renderKitGeneralAdapter; - } - - /** - * The adapter that will be added onto <render-kit> element, to listen the - * events of the children that are displayed in this section, notify the - * section to refresh. - * - * @author sfshi - * - */ - class RenderKitGeneralAdapter extends AdapterImpl { - - public boolean isAdapterForType(Object type) { - if (type == RenderkitGeneralSection.class) - return true; - return false; - } - - public void notifyChanged(Notification msg) { - - if (msg.getEventType() == Notification.ADD - || msg.getEventType() == Notification.REMOVE - || msg.getEventType() == Notification.SET) { - if (msg.getFeature() == FacesConfigPackage.eINSTANCE - .getRenderKitType_RenderKitId() - || msg.getFeature() == FacesConfigPackage.eINSTANCE - .getRenderKitType_RenderKitClass() - || msg.getFeature() == FacesConfigPackage.eINSTANCE - .getRenderKitType_Description() - || msg.getFeature() == FacesConfigPackage.eINSTANCE - .getRenderKitType_DisplayName()) { - refresh(); - } else if (msg.getFeature() == FacesConfigPackage.eINSTANCE - .getDisplayNameType_TextContent() - || msg.getFeature() == FacesConfigPackage.eINSTANCE - .getDescriptionType_TextContent()) { - refresh(); - } - } - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/RenderkitMasterSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/RenderkitMasterSection.java deleted file mode 100644 index 3e8e20f17..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/RenderkitMasterSection.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.section; - -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.edit.command.AddCommand; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.emf.RenderKitType; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.jst.jsf.facesconfig.ui.page.FacesConfigMasterDetailPage; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * @author Bryan Yang - * - */ -public class RenderkitMasterSection extends FacesConfigMasterSection { - - /** - * - * @param parent - * @param managedForm - * @param toolkit - * @param page - */ - public RenderkitMasterSection(Composite parent, IManagedForm managedForm, - FormToolkit toolkit, FacesConfigMasterDetailPage page) { - super(parent, managedForm, toolkit, page, null, null); - getSection().setText(EditorMessages.RenderKitMasterSection_Name); //$NON-NLS-1$ - getSection().setDescription( - EditorMessages.RenderKitMasterSection_Description); - } - - /** - * Config the table viwer, set a filter for it, only the object of - * RenderKitType will be selected. - */ - protected void configViewer(StructuredViewer structuredViewer) { - super.configViewer(structuredViewer); - structuredViewer.addFilter(new ViewerFilter() { - public boolean select(Viewer viewer, Object parentElement, - Object element) { - return FacesConfigPackage.eINSTANCE.getRenderKitType() - .isInstance(element); - } - }); - - } - - /** - * Create a new render kit. - */ - protected void addButtonSelected(SelectionEvent e) { - RenderKitType Renderkit = FacesConfigFactory.eINSTANCE - .createRenderKitType(); - - Command command = AddCommand.create(getEditingDomain(), - this.getInput(), FacesConfigPackage.eINSTANCE - .getFacesConfigType_RenderKit(), Renderkit); - - if (command.canExecute()) { - getEditingDomain().getCommandStack().execute(command); - IStructuredSelection selection = new StructuredSelection(Renderkit); - getStructuredViewer().refresh(); - getStructuredViewer().setSelection(selection); - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ValidatorGeneralSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ValidatorGeneralSection.java deleted file mode 100644 index 649b7f77a..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ValidatorGeneralSection.java +++ /dev/null @@ -1,400 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.section; - -import org.eclipse.core.resources.IProject; -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.impl.AdapterImpl; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.emf.edit.command.AddCommand; -import org.eclipse.emf.edit.command.SetCommand; -import org.eclipse.emf.edit.domain.EditingDomain; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.ClassButtonDialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.IDialogFieldApplyListener; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.LayoutUtil; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.StringDialogField; -import org.eclipse.jst.jsf.facesconfig.emf.DescriptionType; -import org.eclipse.jst.jsf.facesconfig.emf.DisplayNameType; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.emf.ValidatorClassType; -import org.eclipse.jst.jsf.facesconfig.emf.ValidatorIdType; -import org.eclipse.jst.jsf.facesconfig.emf.ValidatorType; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.jst.jsf.facesconfig.ui.IFacesConfigConstants; -import org.eclipse.jst.jsf.facesconfig.ui.page.IFacesConfigPage; -import org.eclipse.jst.jsf.facesconfig.ui.util.ModelUtil; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * @author Bryan Yang - * - */ -public class ValidatorGeneralSection extends AbstractFacesConfigSection { - - private StringDialogField displayNameField; - - private StringDialogField descriptionField; - - private StringDialogField validatorIDField; - - private ClassButtonDialogField validatorClassField; - - private ValidatorGeneralAdapter validatorGeneralAdapter; - - /** - * - * @param parent - * @param managedForm - * @param page - * @param toolkit - */ - public ValidatorGeneralSection(Composite parent, IManagedForm managedForm, - IFacesConfigPage page, FormToolkit toolkit) { - super(parent, managedForm, page, toolkit, null, null); - getSection() - .setText(EditorMessages.ValidatorGeneralSection_Name); - getSection().setDescription( - EditorMessages.ValidatorGeneralSection_Description); - } - - /** - * - */ - protected void createContents(Composite container, FormToolkit toolkit) { - int numberOfColumns = 4; - GridLayout layout = new GridLayout(numberOfColumns, false); - container.setLayout(layout); - GridData td = new GridData(GridData.FILL_HORIZONTAL); - container.setLayoutData(td); - - toolkit.paintBordersFor(container); - displayNameField = new StringDialogField(); - displayNameField - .setLabelText(EditorMessages.ValidatorGeneralSection_Label_DisplayName); - displayNameField.doFillIntoGrid(toolkit, container, numberOfColumns); - - displayNameField - .setDialogFieldApplyListener(new IDialogFieldApplyListener() { - - public void dialogFieldApplied(DialogField field) { - String newDisplayNameValue = ((StringDialogField) field) - .getText().trim(); - Command cmd = null; - ValidatorType validator = (ValidatorType) getInput(); - EditingDomain editingDomain = getEditingDomain(); - if (validator.getDisplayName().size() > 0) { - DisplayNameType displayName = (DisplayNameType) validator - .getDisplayName().get(0); - cmd = SetCommand.create(editingDomain, displayName, - FacesConfigPackage.eINSTANCE - .getDisplayNameType_TextContent(), - newDisplayNameValue); - } else { - DisplayNameType displayNameType = FacesConfigFactory.eINSTANCE - .createDisplayNameType(); - displayNameType.setTextContent(newDisplayNameValue); - displayNameType.eAdapters().add( - getValidatorGeneralAdapter()); - - cmd = AddCommand.create(editingDomain, validator, - FacesConfigPackage.eINSTANCE - .getValidatorType_DisplayName(), - displayNameType); - } - if (cmd.canExecute()) { - editingDomain.getCommandStack().execute(cmd); - } - } - - }); - - descriptionField = new StringDialogField(2); - descriptionField - .setLabelText(EditorMessages.ValidatorGeneralSection_Label_Description); - descriptionField.doFillIntoGrid(toolkit, container, numberOfColumns); - - descriptionField - .setDialogFieldApplyListener(new IDialogFieldApplyListener() { - public void dialogFieldApplied(DialogField field) { - String newDescriptionValue = ((StringDialogField) field) - .getText().trim(); - newDescriptionValue = ModelUtil - .escapeEntities(newDescriptionValue); - Command cmd = null; - ValidatorType validator = (ValidatorType) getInput(); - EditingDomain editingDomain = getEditingDomain(); - if (validator.getDescription().size() > 0) { - DescriptionType description = (DescriptionType) validator - .getDescription().get(0); - cmd = SetCommand.create(editingDomain, description, - FacesConfigPackage.eINSTANCE - .getDescriptionType_TextContent(), - newDescriptionValue); - } else { - DescriptionType description = FacesConfigFactory.eINSTANCE - .createDescriptionType(); - description.setTextContent(newDescriptionValue); - description.eAdapters().add( - getValidatorGeneralAdapter()); - - cmd = AddCommand.create(editingDomain, validator, - FacesConfigPackage.eINSTANCE - .getValidatorType_Description(), - description); - } - if (cmd.canExecute()) { - editingDomain.getCommandStack().execute(cmd); - } - } - }); - - validatorIDField = new StringDialogField(); - // validatorIDField.setRequired(true); - validatorIDField - .setLabelText(EditorMessages.ValidatorGeneralSection_Label_ValidatorID); - validatorIDField.doFillIntoGrid(toolkit, container, numberOfColumns); - validatorIDField - .setDialogFieldApplyListener(new IDialogFieldApplyListener() { - public void dialogFieldApplied(DialogField field) { - ValidatorIdType ValidatorType = FacesConfigFactory.eINSTANCE - .createValidatorIdType(); - ValidatorType - .setTextContent(((StringDialogField) field) - .getText()); - - EditingDomain editingDomain = getEditingDomain(); - if (editingDomain != null) { - Command command = SetCommand.create(editingDomain, - getInput(), FacesConfigPackage.eINSTANCE - .getValidatorType_ValidatorId(), - ValidatorType); - if (command.canExecute()) { - editingDomain.getCommandStack() - .execute(command); - } - } - } - }); - - validatorClassField = new ClassButtonDialogField(null); - // validatorClassField.setRequired(true); - validatorClassField - .setLabelText(EditorMessages.ValidatorGeneralSection_Label_ValidatorClass); - validatorClassField.setProject((IProject) getPage().getEditor() - .getAdapter(IProject.class)); - validatorClassField.doFillIntoGrid(toolkit, container, numberOfColumns); - LayoutUtil.setHorizontalGrabbing(validatorClassField.getTextControl( - toolkit, container)); - - validatorClassField - .setDialogFieldApplyListener(new IDialogFieldApplyListener() { - public void dialogFieldApplied(DialogField field) { - - ValidatorClassType ValidatorClass = FacesConfigFactory.eINSTANCE - .createValidatorClassType(); - ValidatorClass - .setTextContent(((StringDialogField) field) - .getText()); - EditingDomain editingDomain = getEditingDomain(); - if (editingDomain != null) { - Command command = SetCommand.create(editingDomain, - getInput(), FacesConfigPackage.eINSTANCE - .getValidatorType_ValidatorClass(), - ValidatorClass); - if (command.canExecute()) { - editingDomain.getCommandStack() - .execute(command); - } - } - - } - }); - validatorClassField - .setInterface(IFacesConfigConstants.VALIDATOR_INTERFACE); - } - - /** - * - */ - public void refreshAll() { - refresh(); - } - - /** - * - */ - public void refresh() { - super.refresh(); - Object input = this.getInput(); - if (input instanceof ValidatorType) { - ValidatorType validator = (ValidatorType) input; - - if (validator.getDisplayName().size() > 0) { - DisplayNameType displayName = (DisplayNameType) validator - .getDisplayName().get(0); - displayNameField.setTextWithoutUpdate(displayName - .getTextContent()); - } else { - displayNameField.setTextWithoutUpdate(""); - } - - if (validator.getDescription().size() > 0) { - DescriptionType description = (DescriptionType) validator - .getDescription().get(0); - String descriptionString = description.getTextContent(); - descriptionString = ModelUtil - .unEscapeEntities(descriptionString); - descriptionField.setTextWithoutUpdate(descriptionString); - } else { - descriptionField.setTextWithoutUpdate(""); - } - - if (validator.getValidatorId() != null) { - validatorIDField.setTextWithoutUpdate(validator - .getValidatorId().getTextContent()); - } else { - validatorIDField.setTextWithoutUpdate(""); - } - - if (validator.getValidatorClass() != null) { - validatorClassField.setTextWithoutUpdate(validator - .getValidatorClass().getTextContent()); - } else { - validatorClassField.setTextWithoutUpdate(""); - } - } - } - - /** - * Add ValidatorGeneralAdapter onto <validator> and the first <display-name> - * and <description> elements. - */ - protected void addAdaptersOntoInput(Object newInput) { - ValidatorType validator = (ValidatorType) newInput; - if (EcoreUtil.getExistingAdapter(validator, - ValidatorGeneralSection.class) == null) { - - validator.eAdapters().add(getValidatorGeneralAdapter()); - } - - if (validator.getDisplayName().size() > 0) { - DisplayNameType displayName = (DisplayNameType) validator - .getDisplayName().get(0); - if (EcoreUtil.getExistingAdapter(displayName, - ValidatorGeneralSection.class) == null) { - - displayName.eAdapters().add(getValidatorGeneralAdapter()); - } - } - - if (validator.getDescription().size() > 0) { - DescriptionType description = (DescriptionType) validator - .getDescription().get(0); - if (EcoreUtil.getExistingAdapter(description, - ValidatorGeneralSection.class) == null) { - - description.eAdapters().add(getValidatorGeneralAdapter()); - } - } - } - - /** - * Remove ValidatorGeneralAdapter from <validator> and the first - * <display-name> and <description> elements. - */ - protected void removeAdaptersFromInput(Object oldInput) { - ValidatorType validator = (ValidatorType) oldInput; - if (EcoreUtil.getExistingAdapter(validator, - ValidatorGeneralSection.class) != null) { - validator.eAdapters().remove(getValidatorGeneralAdapter()); - } - if (validator.getDisplayName().size() > 0) { - DisplayNameType displayName = (DisplayNameType) validator - .getDisplayName().get(0); - if (EcoreUtil.getExistingAdapter(displayName, - ValidatorGeneralSection.class) != null) { - - displayName.eAdapters().remove(getValidatorGeneralAdapter()); - } - } - - if (validator.getDescription().size() > 0) { - DescriptionType description = (DescriptionType) validator - .getDescription().get(0); - if (EcoreUtil.getExistingAdapter(description, - ValidatorGeneralSection.class) != null) { - - description.eAdapters().remove(getValidatorGeneralAdapter()); - } - } - } - - /** - * - * @return - */ - private Adapter getValidatorGeneralAdapter() { - - if (validatorGeneralAdapter == null) { - validatorGeneralAdapter = new ValidatorGeneralAdapter(); - } - return validatorGeneralAdapter; - } - - /** - * The adapter that will be added onto <validator> element, to listen the - * events of the children that are displayed in this section, notify the - * section to refresh. - * - * @author sfshi - * - */ - class ValidatorGeneralAdapter extends AdapterImpl { - - public boolean isAdapterForType(Object type) { - if (type == ValidatorGeneralSection.class) - return true; - return false; - } - - public void notifyChanged(Notification msg) { - - if (msg.getEventType() == Notification.ADD - || msg.getEventType() == Notification.REMOVE - || msg.getEventType() == Notification.SET) { - if (msg.getFeature() == FacesConfigPackage.eINSTANCE - .getValidatorType_ValidatorId() - || msg.getFeature() == FacesConfigPackage.eINSTANCE - .getValidatorType_ValidatorClass() - || msg.getFeature() == FacesConfigPackage.eINSTANCE - .getValidatorType_Description() - || msg.getFeature() == FacesConfigPackage.eINSTANCE - .getValidatorType_DisplayName()) { - refresh(); - } else if (msg.getFeature() == FacesConfigPackage.eINSTANCE - .getDisplayNameType_TextContent() - || msg.getFeature() == FacesConfigPackage.eINSTANCE - .getDescriptionType_TextContent()) { - refresh(); - } - } - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ValidatorMasterSection.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ValidatorMasterSection.java deleted file mode 100644 index 034e70f52..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/section/ValidatorMasterSection.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.section; - -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.edit.command.AddCommand; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigFactory; -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.emf.ValidatorType; -import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages; -import org.eclipse.jst.jsf.facesconfig.ui.page.FacesConfigMasterDetailPage; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.widgets.FormToolkit; - -/** - * @author Bryan Yang - * - */ -public class ValidatorMasterSection extends FacesConfigMasterSection { - - /** - * - * @param parent - * @param managedForm - * @param toolkit - * @param page - */ - public ValidatorMasterSection(Composite parent, IManagedForm managedForm, - FormToolkit toolkit, FacesConfigMasterDetailPage page) { - super(parent, managedForm, toolkit, page, null, null); - getSection().setText(EditorMessages.ValidatorMasterSection_Name); //$NON-NLS-1$ - getSection().setDescription( - EditorMessages.ValidatorMasterSection_Description); - } - - /** - * Config the table viwer, set a filter for it, only the object of - * ValidatorType will be selected. - */ - protected void configViewer(StructuredViewer structuredViewer) { - super.configViewer(structuredViewer); - structuredViewer.addFilter(new ViewerFilter() { - public boolean select(Viewer viewer, Object parentElement, - Object element) { - return FacesConfigPackage.eINSTANCE.getValidatorType() - .isInstance(element); - } - }); - - } - - /** - * Create a new Validator. - */ - protected void addButtonSelected(SelectionEvent e) { - ValidatorType Validator = FacesConfigFactory.eINSTANCE - .createValidatorType(); - - Command command = AddCommand.create(getEditingDomain(), - this.getInput(), FacesConfigPackage.eINSTANCE - .getFacesConfigType_Validator(), Validator); - - if (command.canExecute()) { - getEditingDomain().getCommandStack().execute(command); - IStructuredSelection selection = new StructuredSelection(Validator); - getStructuredViewer().refresh(); - getStructuredViewer().setSelection(selection); - } - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/util/JavaBeanProperty.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/util/JavaBeanProperty.java deleted file mode 100644 index fcd01ca15..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/util/JavaBeanProperty.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.util; - -import org.eclipse.jdt.core.IMethod; - -/** - * This class is used to encapsulate the property following the java bean's - * spec. - * - * @author xgzhang - * @version - */ -public class JavaBeanProperty { - private String name; - - private String qualifiedType; - - private String signatureType; - - private IMethod getterMethod; - - private IMethod setterMethod; - - /** - * @param name - * @param signatureType - * @param getterMethod - * @param setterMethod - */ - public JavaBeanProperty(String name, String signatureType, - IMethod getterMethod, IMethod setterMethod) { - this.name = name; - this.signatureType = signatureType; - - this.getterMethod = getterMethod; - this.setterMethod = setterMethod; - } - - /** - * @return Returns the name. - */ - public String getName() { - return name; - } - - /** - * @return Returns the setterMethod. - */ - public IMethod getSetterMethod() { - return setterMethod; - } - - /** - * @return Returns the setterMethod. - */ - public IMethod getGetterMethod() { - return getterMethod; - } - - /** - * @return Returns the type. - */ - public String getQualifiedType() { - if (qualifiedType == null) { - IMethod getterSetterMethod = getterMethod != null ? getterMethod - : setterMethod; - - qualifiedType = JavaClassUtils.getQualifiedTypeNameInTypeHierarchy( - getterSetterMethod.getDeclaringType(), signatureType); - } - return qualifiedType; - } - - /** - * @return Returns the signatureType. - */ - public String getSignatureType() { - return signatureType; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/util/JavaBeanUtils.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/util/JavaBeanUtils.java deleted file mode 100644 index 59283e3ad..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/util/JavaBeanUtils.java +++ /dev/null @@ -1,775 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.util; - -import java.beans.Introspector; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.jdt.core.IMethod; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.ITypeHierarchy; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.Signature; -import org.eclipse.jst.jsf.common.ui.internal.utils.JavaModelUtil; - -/** - * This utility class is used to access java bean class, e.g., get java bean's - * property - * - * @author xgzhang - * @version - */ -public final class JavaBeanUtils { - /** - * fully qualified name of a List - */ - private static final String JAVA_UTIL_LIST = "java.util.List"; - - /** - * fully qualifed name of a Map - */ - private static final String JAVA_UTIL_MAP = "java.util.Map"; - - /** - * - */ - private JavaBeanUtils() { - super(); - } - - /** - * get the getter method according to property name - * - * @param type - * @param propertyName - * @return - can be <b>null</b>, if not found - * @throws JavaModelException - * @throws JavaModelException - */ - private static IMethod getPropertyGetterMethod(IType type, - String propertyName) { - if (type == null || !type.exists() || propertyName == null) { - return null; - } - IMethod getterMethod = null; - - String methodBaseName = null; - // Uppercase 1st letter - if (propertyName.length() == 1) { - methodBaseName = propertyName.substring(0, 1).toUpperCase(); - } else { - methodBaseName = propertyName.substring(0, 1).toUpperCase() - + propertyName.substring(1); - } - - String getterMethodName = "get" + methodBaseName; - - getterMethod = type.getMethod(getterMethodName, null); - if (getterMethod == null || !getterMethod.exists() - || !JavaClassUtils.isPublicMethod(getterMethod)) { - getterMethodName = "is" + methodBaseName; - getterMethod = type.getMethod(getterMethodName, null); - - if (getterMethod == null || !getterMethod.exists() - || !JavaClassUtils.isPublicMethod(getterMethod)) { - getterMethod = null; - } - } - return getterMethod; - } - - /** - * get the getter method in the type hierarchy according to property name - * - * @param type - * @param propertyName - * @return - can be <b>null</b>, if not found - * @throws JavaModelException - * @throws JavaModelException - */ - private static IMethod getPropertyGetterMethodInTypeHierarchy(IType type, - String propertyName) throws JavaModelException { - if (type == null || !type.exists() || propertyName == null) { - return null; - } - IMethod getterMethod = null; - - getterMethod = getPropertyGetterMethod(type, propertyName); - - if (getterMethod == null) { - ITypeHierarchy typeHierarchy = null; - typeHierarchy = type.newSupertypeHierarchy(null); - - if (typeHierarchy == null) { - return null; - } - - IType[] superTypes = typeHierarchy.getAllSuperclasses(type); - - if (superTypes == null || superTypes.length == 0) { - return null; - } - for (int i = 0; i < superTypes.length; i++) { - if (!superTypes[i].getFullyQualifiedName().equals( - "java.lang.Object")) { - getterMethod = getPropertyGetterMethod(superTypes[i], - propertyName); - if (getterMethod != null) { - break; - } - } - } - } - return getterMethod; - } - - /** - * get the setter method in the type hierarchy according to property name - * - * @param type - * @param propertyName - * @return - can be <b>null</b>, if not found - * @throws JavaModelException - */ - private static IMethod getPropertySetterMethodInTypeHierarchy(IType type, - String propertyName) throws JavaModelException { - if (type == null || !type.exists() || propertyName == null) { - return null; - } - IMethod setterMethod = null; - - setterMethod = getPropertySetterMethod(type, propertyName); - - if (setterMethod == null) { - ITypeHierarchy typeHierarchy = null; - typeHierarchy = type.newSupertypeHierarchy(null); - - if (typeHierarchy == null) { - return null; - } - - IType[] superTypes = typeHierarchy.getAllSuperclasses(type); - - if (superTypes == null || superTypes.length == 0) { - return null; - } - for (int i = 0; i < superTypes.length; i++) { - if (!superTypes[i].getFullyQualifiedName().equals( - "java.lang.Object")) { - setterMethod = getPropertySetterMethod(superTypes[i], - propertyName); - if (setterMethod != null) { - break; - } - } - } - } - - return setterMethod; - } - - /** - * get the setter method according to property name - * - * @param type - * @param propertyName - * @return - can be <b>null</b>, if not found - * @throws JavaModelException - */ - private static IMethod getPropertySetterMethod(IType type, - String propertyName) throws JavaModelException { - if (type == null || !type.exists() || propertyName == null) { - return null; - } - IMethod setterMethod = null; - - String methodBaseName = null; - // Uppercase 1st letter - if (propertyName.length() == 1) { - methodBaseName = propertyName.substring(0, 1).toUpperCase(); - } else { - methodBaseName = propertyName.substring(0, 1).toUpperCase() - + propertyName.substring(1); - } - - String setterMethodName = "set" + methodBaseName; - - IMethod[] methods = null; - - methods = type.getMethods(); - - if (methods == null || methods.length == 0) { - return null; - } - - for (int i = 0; i < methods.length; i++) { - if (methods[i].getElementName().equals(setterMethodName)) { - if (methods[i] == null || !methods[i].exists() - || !JavaClassUtils.isPublicMethod(methods[i])) { - continue; - } - - // Method must return void - String returnType = methods[i].getReturnType(); - if (!returnType.equals(Signature.SIG_VOID)) { - continue; - } - - String params[] = methods[i].getParameterTypes(); - // method must have only one argument - if (params.length != 1) { - continue; - } - setterMethod = methods[i]; - } - } - - return setterMethod; - } - - /** - * Check whether the propertyName is bean's property or not. - * - * @param baseType - * @param propertyName - * - * @return - True means the property name is valid bean's property, - * otherwise, not. - * - */ - public static boolean isBeanProperty(IType baseType, String propertyName) - { - if (baseType == null || !baseType.exists() || propertyName == null) { - return false; - } - - return (getBeanPropertyType(baseType, propertyName) != null); - } - - /** - * get the bean's property type - * - * @param baseType - * @param propertyName - * @return - can be <b>null</b>, if not found - * - */ - public static IType getBeanPropertyType(IType baseType, String propertyName) { - if (baseType == null || !baseType.exists() || propertyName == null) { - return null; - } - - String typeSignature = null; - IMethod getterMethod = null; - IMethod setterMethod = null; - - IType declaredType = baseType; - try { - getterMethod = getPropertyGetterMethodInTypeHierarchy(baseType, - propertyName); - setterMethod = getPropertySetterMethodInTypeHierarchy(baseType, - propertyName); - } catch (JavaModelException e1) { - // Need not any error handling. - } - - if (getterMethod != null && setterMethod == null) { - declaredType = getterMethod.getDeclaringType(); - try { - typeSignature = getterMethod.getReturnType(); - } catch (JavaModelException e2) { - // Need not any error handling. - } - } else if (setterMethod != null && getterMethod == null) { - declaredType = setterMethod.getDeclaringType(); - typeSignature = setterMethod.getParameterTypes()[0]; - } else if (setterMethod != null && getterMethod != null) { - declaredType = getterMethod.getDeclaringType(); - try { - // FIXME: should check the type hierachy - if (getterMethod.getReturnType().equals( - setterMethod.getParameterTypes()[0])) { - typeSignature = getterMethod.getReturnType(); - } - } catch (JavaModelException e2) { - // Need not any error handling. - } - } - - if (typeSignature == null) { - return null; - } - - IType type = null; - - try { - String typeName = JavaModelUtil.getResolvedTypeName(typeSignature, - declaredType); - if (typeName != null) { - type = baseType.getJavaProject().findType(typeName); - } - } catch (JavaModelException e) { - // Need not any error handling. - } - return type; - } - - /** - * get the bean's property's getter and setter methods. - * - * @param baseType - * @param propertyName - * @return - IMethod[], the first is getter and the second is setter method, - * however, both of them can be null. - */ - public static IMethod[] getBeanPropertyMethods(IType baseType, - String propertyName) { - if (baseType == null || !baseType.exists() || propertyName == null) { - return null; - } - - IMethod[] methods = new IMethod[2]; - - IMethod getterMethod = null; - IMethod setterMethod = null; - try { - getterMethod = getPropertyGetterMethodInTypeHierarchy(baseType, - propertyName); - - setterMethod = getPropertySetterMethodInTypeHierarchy(baseType, - propertyName); - } catch (JavaModelException e) { - // Need not any error handling. - } - - if (getterMethod != null && setterMethod == null) { - methods[0] = getterMethod; - } else if (setterMethod != null && getterMethod == null) { - methods[1] = setterMethod; - } else if (setterMethod != null && getterMethod != null) { - try { - // FIXME: should check the type hierachy - if (getterMethod.getReturnType().equals( - setterMethod.getParameterTypes()[0])) { - methods[0] = getterMethod; - methods[1] = setterMethod; - } - } catch (JavaModelException e1) { - // Need not any error handling. - } - } - - return methods; - } - - /** - * check whether the type implements <code>java.util.List</code> - * - * @param type - * @return - True if the type is the sub class of - * <code>java.util.List</code>, otherwise, not. - */ - public static boolean isListType(IType type) { - if (type == null) { - return false; - } - if (type.getFullyQualifiedName().equalsIgnoreCase(JAVA_UTIL_LIST)) { - return true; - } - - return JavaClassUtils.isSubClassOf(type.getJavaProject(), type - .getFullyQualifiedName(), JAVA_UTIL_LIST); - } - - /** - * check whether the type implements <code>java.util.Map</code> - * - * @param type - * @return - True if the type is the sub class of <code>java.uitl.Map</code>, - * otherwise, not. - */ - public static boolean isMapType(IType type) { - if (type == null) { - return false; - } - if (type.getFullyQualifiedName().equalsIgnoreCase(JAVA_UTIL_MAP)) { - return true; - } - - return JavaClassUtils.isSubClassOf(type.getJavaProject(), type - .getFullyQualifiedName(), JAVA_UTIL_MAP); - } - - /** - * Test for method inclusion in bindings list. - * <p> - * This test has the following conditions: - * </p> - * <ul> - * <li>method starts with <code>get</code></li> - * <li>method has no arguments</li> - * <li>method does not return void</li> - * </ul> - * - * @param method - - * the IMethod to examine - * @return boolean - true, if method satisfies the condition test - */ - public static boolean isGetterMethod(IMethod method) { - try { - if (!JavaClassUtils.isPublicMethod(method)) { - return false; - } - String params[] = method.getParameterTypes(); - // Has no arguments - if (params.length > 0) { - return false; - } - - // Starts with "get" - if (!(method.getElementName().startsWith("get") || method.getElementName().startsWith("is"))) //$NON-NLS-1$ - { - return false; - } - // Does not return void - String rtn = method.getReturnType(); - if (!rtn.equals(Signature.SIG_VOID)) { - return true; - } - } catch (JavaModelException e) { - // Need not any error handling. - } - return false; - } - - /** - * Test for method inclusion in bindings list. - * <p> - * This test has the following conditions: - * </p> - * <ul> - * <li>method starts with <code>set</code></li> - * <li>method returns void</li> - * </ul> - * - * @param method - - * the IMethod to examine - * @return boolean - true, if method satisfies the condition test - */ - public static boolean isSetterMethod(IMethod method) { - try { - if (!JavaClassUtils.isPublicMethod(method)) { - return false; - } - // Starts with "set" - if (!method.getElementName().startsWith("set")) //$NON-NLS-1$ - { - return false; - } - - // the parameter's number should be one. - if (method.getParameterTypes().length != 1) { - return false; - } - // Returns void - String rtn = method.getReturnType(); - if (rtn.equals(Signature.SIG_VOID)) { - return true; - } - } catch (JavaModelException e) { - // Need not any error handling. - } - return false; - } - - /** - * set the first character into low case. - * - * @param str - * @return str with the first char lower cased - */ - public static String toLowCaseFirstChar(String str) { - // change the first alphabet to lowcase. - if (str != null && str.length() > 0) { - if (str.length() == 1) { - str = str.toLowerCase(); - } else { - str = str.substring(0, 1).toLowerCase() + str.substring(1); - } - } - return str; - } - - /** - * set the first character into low case. - * - * @param str - * @return str with the first char upper-cased - */ - public static String toUpperCaseFirstChar(String str) { - // change the first alphabet to lowcase. - if (str != null && str.length() > 0) { - if (str.length() == 1) { - str = str.toUpperCase(); - } else { - str = str.substring(0, 1).toUpperCase() + str.substring(1); - } - } - return str; - } - - /** - * get property name from getter method. - * - * @param method - * @return - can be <b>null</b>, if the method is not a valid getter method - */ - public static String getPropertyNameFromGetterMethod(IMethod method) { - if (!isGetterMethod(method)) { - return null; - } - String methodName = method.getElementName(); - String propertyName = null; - // Starts with "get" - if (methodName.startsWith("get") && methodName.length() > 3) { - propertyName = methodName.substring(3); - } else if (methodName.startsWith("is") && methodName.length() > 2) // Starts - // with - // "is" - { - propertyName = methodName.substring(2); - } - propertyName = Introspector.decapitalize(propertyName); - return propertyName; - } - - /** - * get property name from setter class. - * - * @param method - * @return - can be <b>null</b>, if the method is not a valid setter method - */ - public static String getPropertyNameFromSetterMethod(IMethod method) { - if (!isSetterMethod(method)) { - return null; - } - String methodName = method.getElementName(); - String propertyName = null; - // Starts with "get" - if (methodName.startsWith("set") && methodName.length() > 3) { - propertyName = methodName.substring(3); - } - propertyName = Introspector.decapitalize(propertyName); - return propertyName; - } - - /** - * get the method with the same parameters - * - * @param methods - * @param visitedMethods - * @param foundMethod - * @param foundMethodName - * @param foundParamTypes - * @return - */ - private static IMethod getMethodWithSameParamters(IMethod[] methods, - Map visitedMethods, IMethod foundMethod, String foundMethodName, - String[] foundParamTypes) { - // get all qualified type name for the found method's parameters. - String[] foundParamQulifiedTypeNames = null; - if (foundParamTypes != null && foundParamTypes.length > 0) { - foundParamQulifiedTypeNames = new String[foundParamTypes.length]; - for (int i = 0; i < foundParamTypes.length; i++) { - foundParamQulifiedTypeNames[i] = JavaClassUtils - .getQualifiedTypeNameInTypeHierarchy(foundMethod - .getDeclaringType(), foundParamTypes[i]); - } - } - for (int i = 0; i < methods.length; i++) { - if (visitedMethods.get(methods[i]) != null) { - continue; - } - - if (!methods[i].getElementName().equals(foundMethodName)) { - continue; - } - if (methods[i].getParameterTypes() == null - && foundParamTypes == null) { - return methods[i]; - } else if (methods[i].getParameterTypes() != null - && foundParamTypes != null - && foundParamTypes.length == methods[i].getParameterTypes().length) { - boolean bSameParams = true; - String[] methodParamTypes = methods[i].getParameterTypes(); - for (int j = 0; j < foundParamQulifiedTypeNames.length; j++) { - String methodParamQualifiedTypeName = JavaClassUtils - .getQualifiedTypeNameInTypeHierarchy(methods[i] - .getDeclaringType(), methodParamTypes[j]); - // if the qualified type name is not same or not subclass or - // supper class between each other. - if (!methodParamQualifiedTypeName - .equals(foundParamQulifiedTypeNames[j]) - && !JavaClassUtils.isSubClassOf(methods[i] - .getJavaProject(), - methodParamQualifiedTypeName, - foundParamQulifiedTypeNames[j]) - && !JavaClassUtils.isSubClassOf(methods[i] - .getJavaProject(), - foundParamQulifiedTypeNames[j], - methodParamQualifiedTypeName)) { - bSameParams = false; - break; - } - } - if (bSameParams) { - return methods[i]; - } - } - } - return null; - } - - /** - * Creates an array of bean properties - * - * - * @param classType - * @return it can be <b>null</b>, if property is not found. - */ - public static JavaBeanProperty[] getBeanProperties(IType classType) { - IMethod[] methods; - try { - methods = JavaClassUtils.getMethods(classType); - } catch (JavaModelException e2) { - return null; - } - - return getBeanProperties(classType, methods); - } - - /** - * Creates an array of bean properties - * - * @param type - * @param methods - * - * @return - the array of java bean properties. - */ - public static JavaBeanProperty[] getBeanProperties(IType type, - IMethod[] methods) { - if (methods == null || methods.length == 0) { - return null; - } - - List properties = new ArrayList(); - Map visitedMethods = new HashMap(); - for (int m = 0; m < methods.length; m++) { - String propertyName = null; - // if a property's getter method or setter method already visited, - // just skip it. - if (visitedMethods.get(methods[m]) != null) { - continue; - } - - visitedMethods.put(methods[m], methods[m]); - - // Check getter firstly - propertyName = JavaBeanUtils - .getPropertyNameFromGetterMethod(methods[m]); - - if (propertyName != null && propertyName.length() > 0) //$NON-NLS-1$ - { - String setterMethodName = "set" - + JavaBeanUtils.toUpperCaseFirstChar(propertyName); - - String getterReturnType = null; - try { - getterReturnType = methods[m].getReturnType(); - } catch (JavaModelException e1) { - continue; - } - IMethod setterMethod = getMethodWithSameParamters(methods, - visitedMethods, methods[m], setterMethodName, - new String[] { getterReturnType }); - if (setterMethod != null && setterMethod.exists()) { - visitedMethods.put(setterMethod, setterMethod); - } - - properties.add(new JavaBeanProperty(propertyName, - getterReturnType, methods[m], setterMethod)); - continue; - } - - // Check setter secondly. - propertyName = JavaBeanUtils - .getPropertyNameFromSetterMethod(methods[m]); - - if (propertyName != null && propertyName.length() > 0) //$NON-NLS-1$ - { - // first form of getter method, "get..." - String getterMethodName = "get" - + JavaBeanUtils.toUpperCaseFirstChar(propertyName); - IMethod getterMethod = getMethodWithSameParamters(methods, - visitedMethods, methods[m], getterMethodName, null); - - if (getterMethod != null && getterMethod.exists()) { - try { - if (getterMethod.getReturnType().equals( - methods[m].getParameterTypes()[0])) { - visitedMethods.put(getterMethod, getterMethod); - } - } catch (JavaModelException e) { - // need not error logging - } - } else { - // another form of getter method, "is...". - getterMethodName = "is" - + JavaBeanUtils.toUpperCaseFirstChar(propertyName); - getterMethod = getMethodWithSameParamters(methods, - visitedMethods, methods[m], getterMethodName, null); - try { - if (getterMethod != null - && getterMethod.exists() - && getterMethod.getReturnType().equals( - methods[m].getParameterTypes()[0])) { - visitedMethods.put(getterMethod, getterMethod); - } - } catch (JavaModelException e) { - // need not error logging - } - } - - properties.add(new JavaBeanProperty(propertyName, methods[m] - .getParameterTypes()[0], getterMethod, methods[m])); - continue; - } - } - - JavaBeanProperty[] propertyArray = (JavaBeanProperty[]) properties - .toArray(new JavaBeanProperty[properties.size()]); - - Arrays.sort(propertyArray, new Comparator() { - public int compare(Object o1, Object o2) { - String name1 = ((JavaBeanProperty) o1).getName(); - String name2 = ((JavaBeanProperty) o2).getName(); - return name1.compareTo(name2); - } - }); - return propertyArray; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/util/JavaClassUtils.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/util/JavaClassUtils.java deleted file mode 100644 index 2983664a0..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/util/JavaClassUtils.java +++ /dev/null @@ -1,529 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.util; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.jdt.core.Flags; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IMethod; -import org.eclipse.jdt.core.IPackageDeclaration; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.ITypeHierarchy; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.Signature; -import org.eclipse.jdt.ui.JavaUI; -import org.eclipse.jst.jsf.common.ui.IFileFolderConstants; -import org.eclipse.jst.jsf.common.ui.internal.utils.JavaModelUtil; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.PartInitException; - -/** - * This utility class defines typical operations on java class, such as check - * public constructor, and check type is primitive or not, etc. - * - * @author Jane Cantz, Xiao-guang Zhang - */ -public class JavaClassUtils { - /** - * Determines if a string contains any illegal characters - * - * @param text - - * the string to test - * @return boolean - true if an illegal character is found, otherwise false - */ - public static boolean hasIllegalCharacters(String text) { - if (text.length() == 0 - || !Character.isJavaIdentifierStart(text.charAt(0))) { - return true; - } - for (int i = 1; i < text.length(); i++) { - if (!Character.isJavaIdentifierPart(text.charAt(i))) { - return true; - } - } - return false; - } - - /** - * Test for constructor. - * <p> - * This test determines if the class has any constructors - * </p> - * - * @param methods - - * the IMethod array to examine - * @return boolean - true, if method has no constructors - */ - public static boolean hasNoConstructor(IMethod[] methods) { - for (int m = 0; m < methods.length; m++) { - try { - if (methods[m].isConstructor()) { - return false; - } - } catch (JavaModelException e) { - // suppress: this is possible; fall through - } - } - return true; - } - - /** - * check whether the method is public or not. - * - * @param method - * @return true if method is public - */ - public static boolean isPublicMethod(IMethod method) { - int accessFlags = 0; - - try { - accessFlags = method.getFlags(); - } catch (JavaModelException e) { - return false; - } - - boolean isPublic = Flags.isPublic(accessFlags); - if ((!Flags.isPrivate(accessFlags)) - && (!Flags.isProtected(accessFlags)) - && (!Flags.isPublic(accessFlags))) { - // No specific modifier was set, so assume to be public - isPublic = true; - } - if (!isPublic) { - return false; - } - return true; - } - - /** - * Test for constructor. - * <p> - * This test has the following conditions: - * </p> - * <ul> - * <li>method takes 0 arguments and the method name is the class name: - * <ul> - * <li>takes 0 arguments</li> - * <li>the method name is the class name</li> - * <li>the method returns void</code></li> - * </ul> - * </li> - * </ul> - * - * @param methods - - * the IMethod array to examine - * @return boolean - true, if method is a constructor - */ - public static boolean hasPublicConstructor(IMethod[] methods) { - for (int m = 0; m < methods.length; m++) { - try { - if (methods[m].isConstructor() && isPublicMethod(methods[m])) { - // Constructor must have the following 0 arguments - String[] params = methods[m].getParameterTypes(); - if (params.length == 0) { - // And must return a void - String rtn = methods[m].getReturnType(); - if (rtn.equals(Signature.SIG_VOID)) { - return true; - } - break; - } - } - } catch (JavaModelException e) { - // Nothing to do. - } - } - return false; - } - - /** - * Determines if a datatype is primitive type or part of java.lang or - * java.util package. If not, it is considered to be a bean reference - * - * @param classType - - * the parent class compilation unit - * @param signatureName - - * the datatype of the property - * @return boolean - true, if the datatype is primitive or part of java.lang - * or java.util package - */ - public static boolean isPrimitiveType(IType classType, String signatureName) { - while (signatureName.startsWith("[")) { - signatureName = signatureName.substring(1); - } - int kind = Signature.getTypeSignatureKind(signatureName); - if (kind == Signature.BASE_TYPE_SIGNATURE - || signatureName.equals(Signature.SIG_VOID)) { - // These are true primitive types - return true; - } - - String qualifiedName = getQualifiedTypeNameInTypeHierarchy(classType, - signatureName); - - if ((qualifiedName.startsWith("java.lang")) || (qualifiedName.startsWith("java.util"))) //$NON-NLS-1$ - { - return true; - } - return false; - } - - /** - * get the type from the input class name - * - * @param project - * @param className - * @return - can be null. - */ - public static IType getType(IProject project, String className) { - if (project == null) { - return null; - } - IType cunit = null; - if (className.length() > 0) { - - IJavaProject jProject = JavaCore.create(project); - try { - cunit = jProject.findType(className); - } catch (JavaModelException e) { - // suppress: fall-through and return null - } - } - return cunit; - } - - /** - * open the type in the editor. - * - * @param type - * @return true if the type could opened in an editor - */ - public static boolean openType(IType type) { - if (type == null || !type.exists()) { - return false; - } - - try { - IEditorPart editorPart = JavaUI.openInEditor(type - .getPrimaryElement()); - if (editorPart != null) { - JavaUI.revealInEditor(editorPart, type.getPrimaryElement()); - return true; - } - } catch (PartInitException e) { - // ignore this error. - } catch (JavaModelException e) { - // ignore this error. - } - return false; - } - - /** - * get package name from java source file - * - * @param javaFile - * @return - can be null. - */ - public static String getPackageName(IFile javaFile) { - if (javaFile == null) { - return null; - } - String ext = "." + javaFile.getFileExtension(); //$NON-NLS-1$ - // See if the file is a java file - if (!ext.equalsIgnoreCase(IFileFolderConstants.EXT_JAVA)) { - return null; - } - String packagename = new String(); - ICompilationUnit cunit = JavaCore.createCompilationUnitFrom(javaFile); - try { - IPackageDeclaration[] packages = cunit.getPackageDeclarations(); - if (packages.length == 0) { - packagename = new String(); - } else { - packagename = packages[0].getElementName(); - } - } catch (JavaModelException jme) { - // suppress: fall-through and return an empty string?? TODO:? - } - return packagename; - } - - /** - * copy the array to the list. - * - * @param methodList - * @param methods - */ - private static void copyToMethodList(List methodList, IMethod[] methods) { - if (methods != null && methods.length > 0) { - for (int i = 0; i < methods.length; i++) { - if (!isDuplicateMethod(methodList, methods[i])) { - methodList.add(methods[i]); - } - } - } - } - - /** - * check whether this method is duplicated or not in the existing method - * list. - * - * @param methodList - * @param method - * @return - */ - private static boolean isDuplicateMethod(List methodList, IMethod method) { - if (method == null || !method.exists()) { - return false; - } - - String[] paramTypes = method.getParameterTypes(); - String methodName = method.getElementName(); - - for (Iterator iter = methodList.iterator(); iter.hasNext();) { - IMethod existedMethod = (IMethod) iter.next(); - if (isSameMethodSignature(methodName, paramTypes, existedMethod)) { - return true; - } - } - return false; - } - - /** - * Tests if a method equals to the given signature. Parameter types are only - * compared by the simple name, no resolving for the fully qualified type - * name is done. Constructors are only compared by parameters, not the name. - * - * @param name - * Name of the method - * @param paramTypes - * The type signatures of the parameters e.g. - * <code>{"QString;","I"}</code> - * @param curr - * @return Returns <code>true</code> if the method has the given name and - * parameter types and constructor state. - */ - public static boolean isSameMethodSignature(String name, - String[] paramTypes, IMethod curr) { - if (name.equals(curr.getElementName())) { - String[] currParamTypes = curr.getParameterTypes(); - if (paramTypes.length == currParamTypes.length) { - for (int i = 0; i < paramTypes.length; i++) { - String t1 = Signature.getSimpleName(Signature - .toString(paramTypes[i])); - String t2 = Signature.getSimpleName(Signature - .toString(currParamTypes[i])); - if (!t1.equals(t2)) { - return false; - } - } - return true; - } - } - return false; - } - - /** - * get methods for the class Type including its super class - * - * @param classType - * @return - can be null - * @throws JavaModelException - */ - public static IMethod[] getMethods(IType classType) - throws JavaModelException { - if (classType == null) { - return null; - } - List methodList = new ArrayList(); - IMethod[] methods = classType.getMethods(); - copyToMethodList(methodList, methods); - - ITypeHierarchy typeHierarchy = classType.newSupertypeHierarchy(null); - - if (typeHierarchy != null) { - IType[] superTypes = typeHierarchy.getAllSuperclasses(classType); - - if (superTypes != null && superTypes.length > 0) { - for (int i = 0; i < superTypes.length; i++) { - if (!superTypes[i].getFullyQualifiedName().equals( - "java.lang.Object")) { - methods = superTypes[i].getMethods(); - - copyToMethodList(methodList, methods); - } - } - } - } - - if (methodList != null && methodList.size() > 0) { - IMethod[] validMethods = (IMethod[]) methodList - .toArray(new IMethod[methodList.size()]); - - Arrays.sort(validMethods, new Comparator() { - public int compare(Object o1, Object o2) { - String name1 = ((IMethod) o1).getElementName(); - String name2 = ((IMethod) o2).getElementName(); - return name1.compareTo(name2); - } - }); - return validMethods; - } - return null; - } - - /** - * resolve and get the qualified name for the incomplete typename - * - * @param classType - * @param signatureName - * @return - at least equal to Signature.toString(signatureName). - */ - public static String getQualifiedTypeNameInTypeHierarchy(IType classType, - String signatureName) { - int arrayNum = 0; - while (signatureName.startsWith("[")) { - arrayNum++; - signatureName = signatureName.substring(1); - } - - String qualifiedTypeName = Signature.toString(signatureName); - int kind = Signature.getTypeSignatureKind(signatureName); - if (kind == Signature.BASE_TYPE_SIGNATURE - || signatureName.equals(Signature.SIG_VOID)) { - // Add back array identifiers - while (arrayNum > 0) { - qualifiedTypeName = qualifiedTypeName + "[]"; - arrayNum--; - } - return qualifiedTypeName; - } - - String typeName = Signature.toString(signatureName); - - String foundName = getQualifiedTypeName(classType, typeName); - // if found in current type - if (foundName != null) { - qualifiedTypeName = foundName; - } else // else found in the type hierachy. - { - ITypeHierarchy typeHierarchy = null; - try { - typeHierarchy = classType.newSupertypeHierarchy(null); - } catch (JavaModelException e) { - // Nothing to do. - } - if (typeHierarchy != null) { - IType[] superTypes = typeHierarchy.getAllSupertypes(classType); - - if (superTypes != null && superTypes.length > 0) { - for (int i = 0; i < superTypes.length; i++) { - if (!superTypes[i].getFullyQualifiedName().equals( - "java.lang.Object")) { - foundName = getQualifiedTypeName(superTypes[i], - typeName); - if (foundName != null) { - qualifiedTypeName = foundName; - break; - } - } - } - } - } - } - - // Add back array identifiers - while (arrayNum > 0) { - qualifiedTypeName = qualifiedTypeName + "[]"; - arrayNum--; - } - return qualifiedTypeName; - } - - /** - * resolve and get the qualified name for the incomplete typename - * - * @param classType - * @param typeName - * @return can be null. - */ - public static String getQualifiedTypeName(IType classType, String typeName) { - String qualifiedTypeName = null; - - try { - String[][] resolvedNames = classType.resolveType(typeName); - if (resolvedNames != null && resolvedNames.length > 0) { - qualifiedTypeName = JavaModelUtil.concatenateName( - resolvedNames[0][0], resolvedNames[0][1]); - } - } catch (JavaModelException e1) { - // Nothing to do. - } - - return qualifiedTypeName; - } - - /** - * check whether subclass is sub class of supperclass - * - * @param jProject - * @param subClass - - * fully qualified name of sub class - * @param superClass - - * fully qualified name of super class - * - * @return true if subClass is a sub of superClass - */ - public static boolean isSubClassOf(IJavaProject jProject, String subClass, - String superClass) { - if (jProject == null || subClass == null || superClass == null) { - return false; - } - - try { - IType subClassType = jProject.findType(subClass); - - if (subClassType != null) { - ITypeHierarchy typeHierarchy = null; - try { - typeHierarchy = subClassType.newSupertypeHierarchy(null); - } catch (JavaModelException e) { - // Nothing to do. - } - IType[] superTypes = typeHierarchy - .getAllSupertypes(subClassType); - - if (superTypes != null && superTypes.length > 0) { - for (int i = 0; i < superTypes.length; i++) { - if (superTypes[i].getFullyQualifiedName().equals( - superClass)) { - return true; - } - } - } - } - } catch (JavaModelException e) { - // Nothing to do. - } - return false; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/util/ManagedBeanUtil.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/util/ManagedBeanUtil.java deleted file mode 100644 index c17cb9faf..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/util/ManagedBeanUtil.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.util; - -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jst.jsf.core.jsfappconfig.JSFAppConfigManager; -import org.eclipse.jst.jsf.facesconfig.emf.ManagedBeanType; - -/** - * - * @author sfshi - * - */ -public class ManagedBeanUtil { - - /** - * Determines if the new bean to be added is already a member of the - * configuration set. - * @param project - * - * @param beanName - - * The name of the bean being added - * @return int - 0 if bean doesn't exist, otherwise the choice from the - * Duplicate Bean dialog - */ - public static boolean isBeanDuplicate(IProject project, String beanName) - { - JSFAppConfigManager appCfgMgr = JSFAppConfigManager.getInstance(project); - - if (appCfgMgr != null) - { - List beans = appCfgMgr.getManagedBeans(); - - // Iterate through the bean list - for (Iterator i = beans.iterator(); i.hasNext();) { - Object o = i.next(); - if (o instanceof ManagedBeanType) { - ManagedBeanType mbti = (ManagedBeanType) o; - if (mbti.getManagedBeanName() != null) { - String name = mbti.getManagedBeanName() - .getTextContent(); - if (name != null && name.equals(beanName)) { - return true; - } - } - } - } - - } - return false; - } - - /** - * get the default managed bean name in the current project according to - * reference name - * - * @param project - - * current project - * @param refName - - * seed reference name - * @return String - default managed bean name - */ - public static String getDefaultManagedBeanName(IProject project, - String refName) { - String defaultName = refName; - - int newRefNameIndex = 1; - while (isBeanDuplicate(project, defaultName)) { - defaultName = refName + newRefNameIndex; - newRefNameIndex++; - } - return defaultName; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/util/ModelUtil.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/util/ModelUtil.java deleted file mode 100644 index 1a0030af4..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/util/ModelUtil.java +++ /dev/null @@ -1,180 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.util; - -import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigPackage; -import org.eclipse.jst.jsf.facesconfig.ui.IFacesConfigConstants; - -/** - * @author Zhi-peng Zhang - * @version - */ -public class ModelUtil { - - /** - * Get the super class's name of certain element. For example, a class for - * <action-listener> should implement interface - * "javax.faces.event.ActionListener". - * - * - * - * @param key - * the EClass object of the application child. - * @return the expected super type for a particular element - * TODO: could make common with the faces-config validator - */ - public static String getSuperType(Object key) { - if (key == FacesConfigPackage.eINSTANCE.getActionListenerType()) { - return IFacesConfigConstants.ACTION_LISTENER_INTERFACE; - } - if (key == FacesConfigPackage.eINSTANCE.getNavigationHandlerType()) { - return IFacesConfigConstants.NAVIGATION_HANDLE_SUPER_CLASS; - } - if (key == FacesConfigPackage.eINSTANCE.getPropertyResolverType()) { - return IFacesConfigConstants.PROPERTY_RESOLVER_SUPER_CLASS; - } - if (key == FacesConfigPackage.eINSTANCE.getStateManagerType()) { - return IFacesConfigConstants.STATE_MANAGER_SUPER_CLASS; - } - if (key == FacesConfigPackage.eINSTANCE.getVariableResolverType()) { - return IFacesConfigConstants.VARIABLE_RESOLVER_SUPER_CLASS; - } - if (key == FacesConfigPackage.eINSTANCE.getViewHandlerType()) { - return IFacesConfigConstants.VIEW_HANDLER_SUPER_CLASS; - } - - if (key == FacesConfigPackage.eINSTANCE.getApplicationFactoryType()) { - return IFacesConfigConstants.APPLICATION_FACTORY_SUPER_CLASS; - } - if (key == FacesConfigPackage.eINSTANCE.getFacesContextFactoryType()) { - return IFacesConfigConstants.FACES_CONTEXT_FACTORY_SUPER_CLASS; - } - if (key == FacesConfigPackage.eINSTANCE.getLifecycleFactoryType()) { - return IFacesConfigConstants.LIFECYCLE_FACTORY_SUPER_CLASS; - } - if (key == FacesConfigPackage.eINSTANCE.getRenderKitFactoryType()) { - return IFacesConfigConstants.RENDER_KIT_FACTORY_SUPER_CLASS; - } - - if (key == FacesConfigPackage.eINSTANCE.getPhaseListenerType()) { - return IFacesConfigConstants.PHASE_LISTENER_INTERFACE; - } - - return null; - } - - - /** - * This will take the three pre-defined entities in XML 1.0 (used - * specifically in XML elements) and convert their character representation - * to the appropriate entity reference, suitable for XML element content. - * - * @param str - * <code>String</code> input to escape. - * @return <code>String</code> with escaped content. - */ - public static String escapeEntities(String str) { - if (isEmptyString(str)) { - return ""; - } - - StringBuffer buffer; - char ch; - String entity; - - buffer = null; - for (int i = 0, n = str.length(); i < n; i++) { - ch = str.charAt(i); - switch (ch) { - case '<': - entity = "<"; - break; - case '>': - entity = ">"; - break; - case '\'': - entity = "'"; - break; - case '\"': - entity = """; - break; - case '&': - entity = "&"; - break; - case '\r': - entity = "
"; - break; - case '\t': - entity = "	"; - break; - case '\n': - entity = "
"; - break; - default: - entity = null; - break; - } - if (buffer == null) { - if (entity != null) { - // An entity occurred, so we'll have to use StringBuffer - // (allocate room for it plus a few more entities). - buffer = new StringBuffer(str.length() + 20); - // Copy previous skipped characters and fall through - // to pickup current character - buffer.append(str.substring(0, i)); - buffer.append(entity); - } - } else { - if (entity == null) { - buffer.append(ch); - } else { - buffer.append(entity); - } - } - } - - // If there were any entities, return the escaped characters - // that we put in the StringBuffer. Otherwise, just return - // the unmodified input string. - return (buffer == null) ? str : buffer.toString(); - } - - /** - * @param str - * @return removes XML/HTML escaped characters from str. - */ - public static String unEscapeEntities(String str) { - if (isEmptyString(str)) { - return ""; - } - - String result = new String(str); - - result = result.replaceAll("&", "&"); - result = result.replaceAll("<", "<"); - result = result.replaceAll(">", ">"); - result = result.replaceAll("'", "\'"); - result = result.replaceAll(""", "\""); - result = result.replaceAll("
", "\r"); - result = result.replaceAll("	", "\t"); - result = result.replaceAll("
", "\n"); - - return result; - } - - private static boolean isEmptyString(String value) { - if (value == null || value.length() == 0) { - return true; - } - return false; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/util/WebrootUtil.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/util/WebrootUtil.java deleted file mode 100644 index e0bc3a127..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/util/WebrootUtil.java +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2006 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.util; - -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.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; - - -/** - * This utility class is used to make a bridge between the relative path from - * webroot and physical path in the project. - * - * @author Xiao-guang Zhang - * - */ -public class WebrootUtil extends - org.eclipse.jst.jsf.common.ui.internal.utils.WebrootUtil { - - /** - * get the the project path for webpath The project path is something like - * "/projectname/webroot/filename.jsp", or "/projectname/webroot/folder". - * The project information should be removed from project path, e.g, - * "/filename.jsp" or "/folder/*"; - * @param model - * - * @param strPath - - * the web path - * @return - project path from "/projectname/webroot" - */ - static public String getProjectPath(EObject model, String strPath) { - - IProject project = getProject(model); - - String strProjectPath = ""; - if (strPath != null) { - IPath path = new Path(strPath); - // jsp file - if (path.getFileExtension() != null) { - IPath webContentPath = getWebContentPath(project); - if (webContentPath != null) - strProjectPath = webContentPath.toString() + strPath; - - } else - // jsp folder - { - strPath = new String(strPath.getBytes(), 0, - strPath.length() - 1); - IPath webContentPath = getWebContentPath(project); - if (webContentPath != null) - strProjectPath = webContentPath.toString() + strPath; - } - } - return strProjectPath; - } - - /** - * @param model - - * emf model - * @return the current resource according to EMF model - */ - static public IResource getResource(EObject model) { - IResource resource = null; - - if (model != null && model.eResource() != null) { - URI uri = model.eResource().getURI(); - IPath path = new Path(URI.decode(uri.devicePath())); - - // since the uri format is "platform:/resource/..." - // we will remove the first part - path = path.removeFirstSegments(1); - - IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace() - .getRoot(); - resource = workspaceRoot.findMember(path); - } - - return resource; - } - - /** - * get the current project according to EMF model - * - * @param model - - * emf model - * @return the current project according to EMF model - */ - static public IProject getProject(EObject model) { - IProject project = null; - - IResource resource = getResource(model); - - if (resource != null) { - project = resource.getProject(); - } - - return project; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/wizard/ISummaryDataSource.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/wizard/ISummaryDataSource.java deleted file mode 100644 index ae1fa5e24..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/wizard/ISummaryDataSource.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.wizard; - -import java.util.List; - -/** - * Specifies behavior for a datasource that client wizards use to communicate - * summary information to summary page. - * - * @author plevin - * @version 1.0 - */ -public interface ISummaryDataSource { - /** - * Returns key-value summary data. - * - * @return List - Summary data. - */ - public List getSummaryData(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/wizard/ManagedBeanClassSelectionPage.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/wizard/ManagedBeanClassSelectionPage.java deleted file mode 100644 index c2306cf44..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/wizard/ManagedBeanClassSelectionPage.java +++ /dev/null @@ -1,322 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. All rights reserved. This - * program and the accompanying materials are made available under the terms of - * the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html Contributors: Sybase, - * Inc. - initial API and implementation - ******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.wizard; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jdt.core.IType; -import org.eclipse.jdt.core.JavaConventions; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.ClassButtonDialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogField; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.IDialogFieldChangeListener; -import org.eclipse.jst.jsf.common.ui.internal.dialogfield.LayoutUtil; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.util.JavaClassUtils; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; - -/** - * This class used to select an existing java class or generate a new one. - * However, the actural generated new java class is left to other pages. - * - * @author Xiao-guang Zhang - */ -public class ManagedBeanClassSelectionPage extends WizardPage { - private static final int HORIZONTAL_INDENT_DEFAULT = 25; - - /** the class name */ - private String className; - - /** - * Search Section, including radio button, label, text and browser button. - */ - private Button searchRadioButton; - - private ClassButtonDialogField classSearchDialogField; - - /** selected type */ - private IType searchedType; - - /** Generate radio button */ - private Button createRadioButton; - - private IProject currentProject; - - /** - * Constructor. - * - * @param project - * The project. - */ - public ManagedBeanClassSelectionPage(IProject project) { - super("JavaSelectionWizardPage"); //$NON-NLS-1$ - - currentProject = project; - setTitle(WizardMessages.JavaSelectionWizardPage_Title); - setDescription(WizardMessages.JavaSelectionWizardPage_Description); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) - */ - public void createControl(Composite parent) { - Composite container = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(); - layout.marginWidth = 10; - layout.marginHeight = 5; - container.setLayout(layout); - container.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - final Group group = new Group(container, SWT.NONE); - - group.setLayout(new GridLayout()); - - group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - createSearchSection(group); - createGenerateSection(group); - - setControl(container); - Dialog.applyDialogFont(container); - setPageComplete(classSearchDialogField.getText().length() > 0); - EditorPlugin.getDefault().getWorkbench().getHelpSystem().setHelp( - container, - WizardMessages.JavaSelectionWizardPage_HelpContextID); - } - - /** - * enabled or disabled the search section including the labels and texts - * - * @param enabled - - * enabled or disabled the search section - */ - private void enableSearchSection(boolean enabled) { - classSearchDialogField.setEnabled(enabled); - } - - /** - * Create the search section including the labels, texts, and browser - * buttons - * - * @param parent - - * parent composite control - */ - private void createSearchSection(Composite parent) { - searchRadioButton = new Button(parent, SWT.RADIO); - // JavaSelectionWizardPage.Search = Using an existing Java class - searchRadioButton - .setText(WizardMessages.JavaSelectionWizardPage_Search); - searchRadioButton.setSelection(true); - searchRadioButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - createRadioButton.setSelection(!searchRadioButton - .getSelection()); - enableSearchSection(searchRadioButton.getSelection()); - verifyComplete(); - } - }); - - Composite searchSection = new Composite(parent, SWT.NULL); - - classSearchDialogField = new ClassButtonDialogField(currentProject); - classSearchDialogField.setHyperLink(null); - int numberOfControls = classSearchDialogField.getNumberOfControls(); - - GridLayout layout = new GridLayout(); - layout.numColumns = numberOfControls; - layout.verticalSpacing = 9; - searchSection.setLayout(layout); - searchSection.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - classSearchDialogField.doFillIntoGrid(null, searchSection, - numberOfControls); - - GridData gd = (GridData) classSearchDialogField.getLabelControl(null, - searchSection).getLayoutData(); - gd.horizontalIndent = HORIZONTAL_INDENT_DEFAULT; - - // JavaSelectionWizardPage.Search.ClassName = Qulified class name: - classSearchDialogField - .setLabelText(WizardMessages.JavaSelectionWizardPage_Search_ClassName); - - LayoutUtil.setHorizontalGrabbing(classSearchDialogField.getTextControl( - null, searchSection)); - - classSearchDialogField - .setDialogFieldChangeListener(new IDialogFieldChangeListener() { - public void dialogFieldChanged(DialogField field) { - className = classSearchDialogField.getText(); - verifyComplete(); - } - - }); - - Label searchDesp = new Label(searchSection, SWT.NONE); - searchDesp - .setText(WizardMessages.JavaSelectionWizardPage_Search_Description); - - gd = new GridData(); - gd.horizontalSpan = numberOfControls; - gd.horizontalIndent = HORIZONTAL_INDENT_DEFAULT; - searchDesp.setLayoutData(gd); - } - - /** - * Create the generation section including the labels, texts, and browser - * buttons - * - * @param parent - - * parent composite control - */ - private void createGenerateSection(Composite parent) { - createRadioButton = new Button(parent, SWT.RADIO); - createRadioButton - .setText(WizardMessages.JavaSelectionWizardPage_Create); - createRadioButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - searchRadioButton.setSelection(!createRadioButton - .getSelection()); - enableSearchSection(!createRadioButton.getSelection()); - verifyComplete(); - } - }); - - Composite createSection = new Composite(parent, SWT.NULL); - GridLayout layout = new GridLayout(); - layout.numColumns = 3; - layout.verticalSpacing = 9; - createSection.setLayout(layout); - createSection.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - Label createDesp = new Label(createSection, SWT.NONE); - createDesp - .setText(WizardMessages.JavaSelectionWizardPage_Create_Description); - - GridData gd = new GridData(); - gd.horizontalIndent = HORIZONTAL_INDENT_DEFAULT; - createDesp.setLayoutData(gd); - } - - /** - * create a new java class or not - * - * @return true if the create new java class radio button is selected - */ - public boolean isCreateNewJavaClass() { - return createRadioButton.getSelection(); - } - - /** - * get the selected java type - * - * @return - type - */ - public IType getSelectedType() { - searchedType = JavaClassUtils.getType(currentProject, - classSearchDialogField.getText()); - - return searchedType; - } - - /** - * @return the class name - */ - public String getClassName() { - return className; - } - - /** - * validate the selected or input java type name - * - * @return - */ - private IStatus validateJavaTypeName() { - IStatus status = null; - if (classSearchDialogField.getText().length() == 0) { - status = new Status( - IStatus.ERROR, - EditorPlugin.getPluginId(), - -1, - NLS - .bind( - WizardMessages.JavaSelectionWizardPage_Error_ClassIsEmpty, - classSearchDialogField.getText()), null); - } else { - // ensure the name follows the java conventsions. - status = JavaConventions - .validateJavaTypeName(classSearchDialogField.getText(), JavaCore.VERSION_1_3,JavaCore.VERSION_1_3); - if (status.getSeverity() != IStatus.ERROR) { - // ensure the input or selected type is defined in the current - // project - if (getSelectedType() == null) { - status = new Status( - IStatus.ERROR, - EditorPlugin.getPluginId(), - -1, - NLS - .bind( - WizardMessages.JavaSelectionWizardPage_Error_ClassIsNotDefined, - classSearchDialogField.getText()), - null); - } - } - } - return status; - } - - /** - * verify and update the complete status - */ - private void verifyComplete() { - IStatus status = null; - - if (isCreateNewJavaClass()) { - setPageComplete(true); - setMessage(null); - setErrorMessage(null); - } else { - if (searchRadioButton.getSelection()) { - status = validateJavaTypeName(); - } - String errorMessage = null; - setPageComplete(status.getSeverity() != IStatus.ERROR); - - if (status.getSeverity() == IStatus.ERROR) { - errorMessage = status.getMessage(); - } - - if (errorMessage != null) { - setErrorMessage(errorMessage); - } else { - setErrorMessage(null); - } - - if (status.getSeverity() != IStatus.OK) { - setMessage(status.getMessage()); - } else { - setMessage(null); - } - } - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/wizard/ManagedBeanPropertyPage.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/wizard/ManagedBeanPropertyPage.java deleted file mode 100644 index 0f0185495..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/wizard/ManagedBeanPropertyPage.java +++ /dev/null @@ -1,309 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. All rights reserved. This - * program and the accompanying materials are made available under the terms of - * the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html Contributors: Sybase, - * Inc. - initial API and implementation - ******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.wizard; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jface.wizard.IWizardPage; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.jst.jsf.common.ui.internal.guiutils.SWTUtils; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; -import org.eclipse.jst.jsf.facesconfig.ui.IFacesConfigConstants; -import org.eclipse.jst.jsf.facesconfig.ui.util.JavaClassUtils; -import org.eclipse.jst.jsf.facesconfig.ui.util.ManagedBeanUtil; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; - -/** - * ManangedBeanProperty wizard page used to show properties of the previous - * selected java class, suade services. and set the default values for each - * property. - * - * @author Xiao-guang Zhang, sfshi - */ -public class ManagedBeanPropertyPage extends WizardPage implements ISummaryDataSource { - /** Default height of description Text Control */ - private static final int DESCRIPTION_TEXT_HEIGHT = 60; - - private static final int DEFAULT_WIDTHHINT = 10; - - /** The Text control for managed bean instance name */ - private Text managedBeanNameText; - - /** The Combo control for Project Selection */ - private Combo scopeCombo; - - /** The Text control for managed bean's description */ - private Text managedBeanDescriptionText; - - private String helpID = null; - - private IProject currentProject; - - private String defaultScope; - - /** - * @param defaultScope - * the default scope, if be null, then use "session". - * @param project - */ - public ManagedBeanPropertyPage(String defaultScope, IProject project) { - super("ManagedBeanPropertyWizardPage"); //$NON-NLS-1$); - - this.defaultScope = defaultScope; - currentProject = project; - setTitle(WizardMessages.ManagedBeanPropertyWizardPage_Title); - setDescription(WizardMessages.ManagedBeanPropertyWizardPage_Description); - } - - /* - * (non-Javadoc) - * - * @see WizardPage#createControl(Composite) - */ - public void createControl(Composite parent) { - initializeDialogUnits(parent); - - Composite container = new Composite(parent, SWT.NONE); - GridLayout gl = new GridLayout(); - gl.numColumns = 1; - container.setLayout(gl); - GridData gridData = new GridData(GridData.FILL_BOTH); - container.setLayoutData(gridData); - - createGeneralSection(container); - - setControl(container); - - setPageComplete(false); - - if (helpID != null) { - EditorPlugin.getDefault().getWorkbench().getHelpSystem().setHelp( - getControl(), helpID); - } - } - - /** - * create managed bean 's configuration group - * - * @param container - */ - private void createGeneralSection(Composite container) { - Group generalSection = new Group(container, SWT.NONE); - - // ManagedBeanPropertyWizardPage.General = General - generalSection - .setText(WizardMessages.ManagedBeanPropertyWizardPage_General); - - GridLayout gl = new GridLayout(); - // gl.marginHeight = 20; - gl.numColumns = 2; - generalSection.setLayout(gl); - GridData gridData = new GridData(GridData.FILL_HORIZONTAL); - generalSection.setLayoutData(gridData); - - SWTUtils - .createLabel( - generalSection, - WizardMessages.ManagedBeanPropertyWizardPage_ManagedBeanName, - 1); - - managedBeanNameText = SWTUtils.createTextBox(generalSection, 1); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan = 1; - gd.widthHint = DEFAULT_WIDTHHINT; - managedBeanNameText.setLayoutData(gd); - - managedBeanNameText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - // dialogChanged(); - if (isValidManagedBeanName(true)) { - setPageComplete(true); - } else { - setPageComplete(false); - } - } - }); - - SWTUtils - .createLabel( - generalSection, - WizardMessages.ManagedBeanPropertyWizardPage_ManagedBeanScope, - 1); //$NON-NLS-1$ - - String[] items = { - IFacesConfigConstants.MANAGED_BEAN_SCOPE_APPLICATION, - IFacesConfigConstants.MANAGED_BEAN_SCOPE_SESSION, - IFacesConfigConstants.MANAGED_BEAN_SCOPE_REQUEST, - IFacesConfigConstants.MANAGED_BEAN_SCOPE_NONE }; - - scopeCombo = SWTUtils.createCombo(generalSection, items, 1); - gd = new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan = 1; - gd.widthHint = DEFAULT_WIDTHHINT; - scopeCombo.setLayoutData(gd); - - Label labelDesp = SWTUtils - .createLabel( - generalSection, - WizardMessages.ManagedBeanPropertyWizardPage_ManagedBeanDescription, - 1); //$NON-NLS-1$ - - gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); - labelDesp.setLayoutData(gd); - - managedBeanDescriptionText = SWTUtils.createTextBoxScrollable( - generalSection, 1, -1, DESCRIPTION_TEXT_HEIGHT); - - } - - /** - * Validates the managed bean Name entry - * - * @param reportError - - * true, to report errors. - * @return boolean - the valid state of the data entered - */ - private boolean isValidManagedBeanName(boolean reportError) { - if (managedBeanNameText.getText().length() == 0) { - if (reportError) { - setErrorMessage(WizardMessages.ManagedBeanPropertyWizardPage_Warning_MissingManagedBeanName); //$NON-NLS-1$ - } - return false; - } else if (JavaClassUtils.hasIllegalCharacters(managedBeanNameText - .getText())) { - if (reportError) { - setErrorMessage(WizardMessages.ManagedBeanPropertyWizardPage_Warning_InvalidManagedBeanName); //$NON-NLS-1$ - } - return false; - } else { - if (ManagedBeanUtil.isBeanDuplicate(currentProject, - managedBeanNameText.getText())) { - if (reportError) { - setErrorMessage(WizardMessages.ManagedBeanPropertyWizardPage_Warning_DuplicateManagedBeanName); - } - return false; - } - - } - - setErrorMessage(null); - return true; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.wizard.IWizardPage#setPreviousPage(org.eclipse.jface.wizard.IWizardPage) - */ - public void setPreviousPage(IWizardPage page) { - super.setPreviousPage(page); - initialize(); - } - - protected void initialize() { - if (defaultScope != null && defaultScope.length() > 0) - scopeCombo.setText(defaultScope); - else - scopeCombo.setText("session"); - - if (((NewManagedBeanWizard) getWizard()).getSuggestedBeanName() != null) { - this.managedBeanNameText - .setText(((NewManagedBeanWizard) getWizard()) - .getSuggestedBeanName()); - } else { - String beanName; - if (this.getPreviousPage() instanceof ManagedBeanClassSelectionPage) { - beanName = ((ManagedBeanClassSelectionPage) this.getPreviousPage()) - .getClassName(); - } else { - beanName = ((NewJavaClassPage) this.getPreviousPage()) - .getTypeName(); - } - beanName = beanName.substring(beanName.lastIndexOf(".") + 1); - if (beanName != null && beanName.length() > 0) { - beanName = (beanName.substring(0, 1)).toLowerCase() - + (beanName.substring(1)); - - beanName = ManagedBeanUtil.getDefaultManagedBeanName( - currentProject, beanName); - - } else - beanName = ""; - managedBeanNameText.setText(beanName); - } - } - - /** - * Returns key-value summary data. - * - * @return List - Summary data. - */ - public List getSummaryData() { - List data = new ArrayList(); - - data - .add(new String[] { - WizardMessages.NewJavaManagedBeanWizard_Summary_ManagedBeanName, - getManagedBeanName() }); //$NON-NLS-1$ - data - .add(new String[] { - WizardMessages.NewJavaManagedBeanWizard_Summary_ManagedBeanScope, - getManagedBeanScope() }); - data.add(new String[] { - WizardMessages.NewJavaManagedBeanWizard_Summary_ClassName, - getManagedBeanClass() }); - - data - .add(new String[] { - WizardMessages.NewJavaManagedBeanWizard_Summary_Description, - getManagedBeanDescription() }); - return data; - } - - public String getManagedBeanName() { - return this.managedBeanNameText.getText().trim(); - } - - public String getManagedBeanClass() { - if (this.getPreviousPage() instanceof ManagedBeanClassSelectionPage) { - return ((ManagedBeanClassSelectionPage) this.getPreviousPage()).getClassName(); - } else if (this.getPreviousPage() instanceof NewJavaClassPage) { - NewJavaClassPage newJavaClassPage = (NewJavaClassPage) this.getPreviousPage(); - StringBuffer buffer = new StringBuffer(); - if (newJavaClassPage.getPackageText() != null - && newJavaClassPage.getPackageText().length() > 0) { - buffer.append(newJavaClassPage.getPackageText()); - buffer.append("."); //$NON-NLS-1$ - } - buffer.append(newJavaClassPage.getTypeName()); - return buffer.toString(); - } - - return "";//$NON-NLS-1$ - } - - public String getManagedBeanScope() { - return this.scopeCombo.getText().trim(); - } - - public String getManagedBeanDescription() { - return this.managedBeanDescriptionText.getText().trim(); - } -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/wizard/NewJavaClassPage.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/wizard/NewJavaClassPage.java deleted file mode 100644 index 73285acd6..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/wizard/NewJavaClassPage.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sybase, Inc. - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.wizard; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.wizard.IWizardPage; - -/** - * Wizard page to create a new class. - * - * @author Xiao-guang Zhang - * - */ -public class NewJavaClassPage extends org.eclipse.jdt.ui.wizards.NewClassWizardPage - implements ISummaryDataSource { - - private IProject currentProject; - - public NewJavaClassPage(IProject project) { - super(); - currentProject = project; - setPageComplete(false); - } - - public void initialize() { - if (getPackageFragmentRoot() == null - || currentProject != getPackageFragmentRoot().getJavaProject() - .getProject()) { - IJavaProject jProject = JavaCore.create(currentProject); - StructuredSelection selection = new StructuredSelection(jProject); - init(selection); - } - } - - private boolean isSkipped() { - if ((getPreviousPage() instanceof ManagedBeanClassSelectionPage) - && !((ManagedBeanClassSelectionPage) getPreviousPage()).isCreateNewJavaClass()) - return true; - return false; - } - - public List getSummaryData() { - List data = new ArrayList(); - - if (!isSkipped()) { - data - .add(new String[] { - WizardMessages.NewJavaManagedBeanWizard_Summary_SourceFolder, - getPackageFragmentRootText(), }); //$NON-NLS-1$ - - data - .add(new String[] { - WizardMessages.NewJavaManagedBeanWizard_Summary_PackageName, //$NON-NLS-1$ - getPackageText(), }); - - data - .add(new String[] { - WizardMessages.NewJavaManagedBeanWizard_Summary_TypeName, //$NON-NLS-1$ - getTypeName() }); - } - return data; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.wizard.IWizardPage#setPreviousPage(org.eclipse.jface.wizard.IWizardPage) - */ - public void setPreviousPage(IWizardPage page) { - super.setPreviousPage(page); - initialize(); - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/wizard/NewManagedBeanWizard.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/wizard/NewManagedBeanWizard.java deleted file mode 100644 index 4226952ae..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/wizard/NewManagedBeanWizard.java +++ /dev/null @@ -1,229 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. All rights reserved. This - * program and the accompanying materials are made available under the terms of - * the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html Contributors: Sybase, - * Inc. - initial API and implementation - ******************************************************************************/ - -package org.eclipse.jst.jsf.facesconfig.ui.wizard; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.jface.wizard.IWizardPage; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.jst.jsf.common.ui.internal.logging.Logger; -import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin; - -/** - * The wizard for creating a managed bean on faces config model. - * - * @author Xiao-guang Zhang, sfshi - */ -public class NewManagedBeanWizard extends Wizard implements ISummaryDataSource { - - /** log instance */ - private static final Logger log = EditorPlugin - .getLogger(NewManagedBeanWizard.class); - - /** - * The wizard page where user can select a Java class for the managed bean - * to be created. - */ - private ManagedBeanClassSelectionPage managedBeanClassSelectionPage; - - /** - * The wizard page where user can create a new Java class for the managed - * bean to be created. - */ - private NewJavaClassPage newJavaClassPage; - - private ManagedBeanPropertyPage managedBeanPropertyPage; - - private String managedBeanName; - - private String managedBeanScope; - - private String managedBeanClass; - - private String managedBeanDescription; - - private IProject project; - - /** - * the suggested name for the managed bean, if setted, then use it in - * ManagedBeanPropertyWizardPage. - */ - private String suggestedBeanName; - - private String defaultScope; - - /** - * Constructor - * - * @param project - * The project. - */ - public NewManagedBeanWizard(IProject project) { - super(); - setWindowTitle(WizardMessages.NewManagedBeanWizardBase_Title); - this.project = project; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.jsf.facesconfig.ui.wizards.NewWizard#addPages() - */ - public void addPages() { - setDialogSettings(EditorPlugin.getDefault().getDialogSettings()); - - // add java source selection page. - managedBeanClassSelectionPage = new ManagedBeanClassSelectionPage(project); - addPage(managedBeanClassSelectionPage); - - // add the class type page - newJavaClassPage = new NewJavaClassPage(project); - addPage(newJavaClassPage); - - managedBeanPropertyPage = new ManagedBeanPropertyPage(defaultScope, project); - addPage(managedBeanPropertyPage); - - // // add the summary page - SummaryPage summaryPage = new SummaryPage(this); - addPage(summaryPage); - summaryPage - .setDescription(WizardMessages.NewJavaManagedBeanWizard_SummaryPage_Description); - } - - /** - * Skip the NewJavaClassPage when user select "Using an existing class" on the - * ManagedBeanClassSelectionPage. - */ - public IWizardPage getNextPage(IWizardPage page) { - IWizardPage nextPage = super.getNextPage(page); - if (page instanceof ManagedBeanClassSelectionPage - && !((ManagedBeanClassSelectionPage) page).isCreateNewJavaClass()) { - ((WizardPage) nextPage).setPageComplete(true); - return getNextPage(nextPage); - } - return nextPage; - } - - public boolean performFinish() { - - managedBeanName = managedBeanPropertyPage.getManagedBeanName(); - managedBeanClass = managedBeanPropertyPage.getManagedBeanClass(); - managedBeanScope = managedBeanPropertyPage.getManagedBeanScope(); - managedBeanDescription = managedBeanPropertyPage.getManagedBeanDescription(); - if (managedBeanClassSelectionPage.isCreateNewJavaClass()) - createNewJavaClass(); - - return true; - } - - /** - * create a new java class according to current inputs in - * NewClassWizardPage. - */ - private void createNewJavaClass() { - try { - newJavaClassPage.createType(new NullProgressMonitor()); - } catch (CoreException e) { - log.info("NewJavaManagedBeanWizard.Error.CreateType", e); //$NON-NLS-1$ - - EditorPlugin.getAlerts().error( - "NewJavaManagedBeanWizard.Alert.CreateType.Title", //$NON-NLS-1$ - "NewJavaManagedBeanWizard.Alert.CreateType.Description"); //$NON-NLS-1$ - return; - } catch (InterruptedException e) { - log.info("NewJavaManagedBeanWizard.Error.CreateType", e); //$NON-NLS-1$ - EditorPlugin.getAlerts().error( - "NewJavaManagedBeanWizard.Alert.CreateType.Title", //$NON-NLS-1$ - "NewJavaManagedBeanWizard.Alert.CreateType.Description"); //$NON-NLS-1$ - return; - } - newJavaClassPage.getCreatedType(); - } - - /** - * @return the suggested bean name - */ - public String getSuggestedBeanName() { - return suggestedBeanName; - } - - /** - * Set a name for the new managed bean, this name will be shown in the - * ManagedBeanPropertyWizardPage. If don't set the name, then will get a - * default bean name from the managed bean class name. - * - * @param suggestedBeanName - */ - public void setSuggestedBeanName(String suggestedBeanName) { - this.suggestedBeanName = suggestedBeanName; - } - - /** - * @return the default scope value - */ - public String getDefaultScope() { - return defaultScope; - } - - /** - * set a default scope value for this new managed bean. - * - * @param defaultScope - */ - public void setDefaultScope(String defaultScope) { - this.defaultScope = defaultScope; - } - - /** - * @return the class name - */ - public String getManagedBeanClass() { - return managedBeanClass; - } - - /** - * @return the bean description - */ - public String getManagedBeanDescription() { - return managedBeanDescription; - } - - /** - * @return the managed bean's symbolic name - */ - public String getManagedBeanName() { - return managedBeanName; - } - - /** - * @return the managed bean's scope - */ - public String getManagedBeanScope() { - return managedBeanScope; - } - - public List getSummaryData() { - List data = new ArrayList(); - IWizardPage[] pages = getPages(); - - for (int i = 0; i < pages.length; i++) { - if (pages[i] instanceof ISummaryDataSource) { - - data.addAll(((ISummaryDataSource) pages[i]).getSummaryData()); - } - } - return data; - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/wizard/SummaryPage.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/wizard/SummaryPage.java deleted file mode 100644 index a62ede967..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/wizard/SummaryPage.java +++ /dev/null @@ -1,147 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 Sybase, Inc. and others. All rights reserved. This - * program and the accompanying materials are made available under the terms of - * the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html Contributors: Sybase, - * Inc. - initial API and implementation - ******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.wizard; - -import org.eclipse.jface.viewers.ColumnPixelData; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.jst.jsf.common.ui.internal.guiutils.SWTUtils; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.TableItem; - -/** - * Common wizard page used to summarize information entered in previous pages. - * - * @author plevin - * @version 1.0 - */ -public class SummaryPage extends WizardPage -{ - private static final String WIZARD_SUMMARY_PAGE = "WizardSummaryPage"; - - /** The source of the summary items */ - private ISummaryDataSource source; - - /** The table control that displays the summary items */ - private Table table; - - /** - * This Constructor creates the summary page - */ - public SummaryPage() - { - super( WIZARD_SUMMARY_PAGE ); - setTitle( WizardMessages.WizardSummaryPage_Title_WizardSummary ); - setDescription( WizardMessages.WizardSummaryPage_Summary_SummaryDesc ); - } - - /** - * This Constructor initializes the data source. - * - * @param source - - * Summary data source - */ - public SummaryPage( ISummaryDataSource source ) - { - this(); - this.source = source; - } - - /** - * Determines if the wizard can enable the Next button - * - * @return boolean - the state of the Next button - */ - public boolean canFlipToNextPage() - { - return false; - } - - /** - * Creates the page controls - * - * @param parent - - * the wizard composite - */ - public void createControl( Composite parent ) - { - - Composite composite = SWTUtils.createComposite( parent, 1 ); - - table = new Table( composite, SWT.BORDER ); - table.setLayoutData( new GridData( GridData.FILL_BOTH ) ); - table.setHeaderVisible( true ); - table.setLinesVisible( true ); - - TableLayout layout = new TableLayout(); - table.setLayout( layout ); - - layout.addColumnData( new ColumnPixelData( 163 ) ); - layout.addColumnData( new ColumnPixelData( 350 ) ); - - TableColumn keyCol = new TableColumn( table, SWT.NONE ); - keyCol.setText( WizardMessages.WizardSummaryPage_Label_Field ); - - TableColumn valueCol = new TableColumn( table, SWT.NONE ); - valueCol - .setText( WizardMessages.WizardSummaryPage_Label_Value ); - - setControl( composite ); - setPageComplete( true ); - } - - /** - * Populates the table with summary information. - */ - public void loadSummaryData() - { - if ( source == null ) - { - return; - } - Object[] data = source.getSummaryData().toArray(); - table.removeAll(); - for ( int i = 0; i < data.length; i++ ) - { - TableItem item = new TableItem( table, SWT.NONE ); - item.setText( (String[]) data[i] ); - } - return; - } - - /** - * Sets summary page data source. - * - * @param s - - * Data source. - */ - public void setSummaryDataSource( ISummaryDataSource s ) - { - source = s; - } - - /** - * Populates the table with summary items when the page becomes visible. - * - * @param visible - - * the visible state of the page - */ - public void setVisible( boolean visible ) - { - super.setVisible( visible ); - - if ( visible == true ) - { - loadSummaryData(); - } - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/wizard/WizardMessages.java b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/wizard/WizardMessages.java deleted file mode 100644 index d9a162da0..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/wizard/WizardMessages.java +++ /dev/null @@ -1,199 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2006 Oracle Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.facesconfig.ui.wizard; - -import org.eclipse.osgi.util.NLS; - -public final class WizardMessages extends NLS { - - private static final String BUNDLE_NAME = "org.eclipse.jst.jsf.facesconfig.ui.wizard.WizardMessages"; - - private WizardMessages() { - // Do not instantiate - } - - static { - NLS.initializeMessages(BUNDLE_NAME, WizardMessages.class); - } - - public static String NewManagedBeanWizardBase_Type; - - public static String NewManagedBeanWizardBase_Description; - - public static String NewManagedBeanWizardBase_Title; - - public static String NewManagedBeanCreationWizard_Title; - - public static String IntroWizardPage_Title; - - public static String IntroWizardPage_Intro; - - public static String ManagedBeanWizardSelectionPage_Title; - - public static String ManagedBeanWizardSelectionPage_Description; - - public static String ManagedBeanWizardSelectionPage_Group; - - public static String ManagedBeanWizardSelectionPage_HelpContextID; - - public static String Registry_LoadWizard_Error; - - public static String NewWizard_Title_WizardDefault; - - public static String ManagedBeanPropertyWizardPage_Title; - - public static String ManagedBeanPropertyWizardPage_Description; - - public static String ManagedBeanPropertyWizardPage_General; - - public static String ManagedBeanPropertyWizardPage_ManagedBeanName; - - public static String ManagedBeanPropertyWizardPage_ManagedBeanScope; - - public static String ManagedBeanPropertyWizardPage_ManagedBeanDescription; - - public static String ManagedBeanPropertyWizardPage_ManagedBeanProperty; - - public static String ManagedBeanPropertyWizardPage_PropertyName; - - public static String ManagedBeanPropertyWizardPage_Type; - - public static String ManagedBeanPropertyWizardPage_Value; - - public static String ManagedBeanPropertyWizardPage_Button_Add; - - public static String ManagedBeanPropertyWizardPage_Button_Edit; - - public static String ManagedBeanPropertyWizardPage_Button_Remove; - - public static String ManagedBeanPropertyWizardPage_Warning_MissingManagedBeanName; - - public static String ManagedBeanPropertyWizardPage_Warning_InvalidManagedBeanName; - - public static String ManagedBeanPropertyWizardPage_Warning_DuplicateManagedBeanName; - - public static String ManagedBeanPropertyEditDialog_PropertyName; - - public static String ManagedBeanPropertyEditDialog_DataType; - - public static String ManagedBeanPropertyEditDialog_InitialValue; - - public static String ManagedBeanPropertyEditDialog_Title_NewPropertyEntry; - - public static String ManagedBeanPropertyEditDialog_Title_ExistingPropertyEntry; - - public static String FacesConfigSelectionWizardPage_Title; - - public static String FacesConfigSelectionWizardPage_Description; - - public static String FacesConfigSelectionWizardPage_Project; - - public static String FacesConfigSelectionWizardPage_FacesConfig; - - public static String FacesConfigSelectionWizardPage_FacesConfig_Browser; - - public static String FacesConfigSelectionWizardPage_Warning_MissingProjectName; - - public static String FacesConfigSelectionWizardPage_Warning_MissingFacesConfigName; - - public static String FacesConfigSelectionWizardPage_Warning_InvalidFacesConfigName; - - public static String FacesConfigSelectionWizardPage_Warning_InvalidFacesConfigContent; - - public static String FacesConfigSelectionWizardPage_Warning_FacesConfigNotDefinedInWebDotXML; - - public static String FacesConfigSelectionWizardPage_HelpContextID; - - public static String FacesConfigFileSelectionDialog_Title; - - public static String FacesConfigFileSelectionDialog_Description; - - public static String JavaSelectionWizardPage_Title; - - public static String JavaSelectionWizardPage_Description; - - public static String JavaSelectionWizardPage_Group; - - public static String JavaSelectionWizardPage_Search; - - public static String JavaSelectionWizardPage_Search_Description; - - public static String JavaSelectionWizardPage_Search_ClassName; - - public static String JavaSelectionWizardPage_Search_ClassName_Browse; - - public static String JavaSelectionWizardPage_Create; - - public static String JavaSelectionWizardPage_Create_Description; - - public static String JavaSelectionWizardPage_FindType; - - public static String JavaSelectionWizardPage_FindType_Filter; - - public static String JavaSelectionWizardPage_Error_ClassIsEmpty; - - public static String JavaSelectionWizardPage_Error_ClassIsNotDefined; - - public static String JavaSelectionWizardPage_HelpContextID; - - public static String NewJavaManagedBeanWizard_Summary_ProjectName; - - public static String NewJavaManagedBeanWizard_Summary_FacesConfigFileName; - - public static String NewJavaManagedBeanWizard_Summary_TypeName; - - public static String NewJavaManagedBeanWizard_Summary_PackageName; - - public static String NewJavaManagedBeanWizard_Summary_SourceFolder; - - public static String NewJavaManagedBeanWizard_Summary_ManagedBeanName; - - public static String NewJavaManagedBeanWizard_Summary_ManagedBeanScope; - - public static String NewJavaManagedBeanWizard_Summary_ClassName; - - public static String NewJavaManagedBeanWizard_Summary_Description; - - public static String NewJavaManagedBeanWizard_SummaryPage_Description; - - public static String NewJavaManagedBeanWizard_Task_CreateNewManagedBean; - - public static String NewJavaManagedBeanWizard_Task_CreateNewJavaClass; - - public static String DuplicateBeanWizard_Title; - - public static String DuplicateBeanPage_Title; - - public static String DuplicateBeanPage_Description; - - public static String DuplicateBeanGroup_Group_Label; - - public static String DuplicateBeanGroup_OverwriteButton_Text; - - public static String DuplicateBeanGroup_NewButton_Text; - - public static String DuplicateBeanGroup_NewNameDialogField_Label; - - public static String DuplicateBeanGroup_Error_EmptyManagedBeanName; - - public static String DuplicateBeanGroup_Error_InvalidManagedBeanName; - - public static String DuplicateBeanGroup_Error_DuplicatedManagedBeanName; - - public static String WizardSummaryPage_Title_WizardSummary; - - public static String WizardSummaryPage_Summary_SummaryDesc; - - public static String WizardSummaryPage_Label_Field; - - public static String WizardSummaryPage_Label_Value; - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/wizard/WizardMessages.properties b/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/wizard/WizardMessages.properties deleted file mode 100644 index b63e5405f..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.facesconfig.ui/src/org/eclipse/jst/jsf/facesconfig/ui/wizard/WizardMessages.properties +++ /dev/null @@ -1,128 +0,0 @@ -############################################################################### -# Copyright (c) 2001, 2006 Oracle Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# Oracle Corporation - initial API and implementation -############################################################################### -NewManagedBeanWizardBase_Type = ManagedBeanTypeName -NewManagedBeanWizardBase_Description = ManagedBeanTypeDescription -NewManagedBeanWizardBase_Title = New Managed Bean Wizard - -NewManagedBeanCreationWizard_Title = Create a Managed Bean - -IntroWizardPage_Title = Introduction Page -IntroWizardPage_Intro = This wizard walks through the steps to create a managed bean. - -ManagedBeanWizardSelectionPage_Title = Managed Bean Selection Page -ManagedBeanWizardSelectionPage_Description = Select a managed bean type to proceed -ManagedBeanWizardSelectionPage_Group = Please select the managed bean type: -ManagedBeanWizardSelectionPage_HelpContextID = com.sybase.stf.jmt.new_managedbean_wizard - -Registry_LoadWizard_Error = Error loading wizard element, couldn't initialize! -#################################################### -# Resource message for NewWizard -#################################################### -NewWizard_Title_WizardDefault = call setWindowTitle(String) in your wizard sub-class - -################################################################## -# Resource message for NewJavaManagedBeanWizards and its' pages. -################################################################## -ManagedBeanPropertyWizardPage_Title = Managed Bean Configuration -ManagedBeanPropertyWizardPage_Description = Set managed bean's name and scope, and create or update Managed Bean's properties, their types and default values. - -ManagedBeanPropertyWizardPage_General = General - -ManagedBeanPropertyWizardPage_ManagedBeanName = Name: -ManagedBeanPropertyWizardPage_ManagedBeanScope = Scope: -ManagedBeanPropertyWizardPage_ManagedBeanDescription = Description: - -ManagedBeanPropertyWizardPage_ManagedBeanProperty = Properties: -ManagedBeanPropertyWizardPage_PropertyName = Property Name -ManagedBeanPropertyWizardPage_Type = Property Type -ManagedBeanPropertyWizardPage_Value = Value -ManagedBeanPropertyWizardPage_Button_Add = Add... -ManagedBeanPropertyWizardPage_Button_Edit = Edit... -ManagedBeanPropertyWizardPage_Button_Remove = Remove - -ManagedBeanPropertyWizardPage_Warning_MissingManagedBeanName = Managed bean name must be entered! -ManagedBeanPropertyWizardPage_Warning_InvalidManagedBeanName = Managed bean name is not valid! -ManagedBeanPropertyWizardPage_Warning_DuplicateManagedBeanName = Managed bean name can not be duplicate! - -ManagedBeanPropertyEditDialog_PropertyName = Property name: -ManagedBeanPropertyEditDialog_DataType = Data type: -ManagedBeanPropertyEditDialog_InitialValue = Initial value: - -ManagedBeanPropertyEditDialog_Title_NewPropertyEntry = New Property Entry -ManagedBeanPropertyEditDialog_Title_ExistingPropertyEntry = Existing Property Entry - -FacesConfigSelectionWizardPage_Title = Faces-Config File -FacesConfigSelectionWizardPage_Description = Select an existing faces-config file, such as faces-config.xml, to save the new managed bean. - -FacesConfigSelectionWizardPage_Project = Project name: -FacesConfigSelectionWizardPage_FacesConfig = Faces-Config file: -FacesConfigSelectionWizardPage_FacesConfig_Browser = Browse... - -FacesConfigSelectionWizardPage_Warning_MissingProjectName = Project name must be entered! -FacesConfigSelectionWizardPage_Warning_MissingFacesConfigName = Faces-Config file name must be entered! -FacesConfigSelectionWizardPage_Warning_InvalidFacesConfigName = Faces-config file name does not exist! -FacesConfigSelectionWizardPage_Warning_InvalidFacesConfigContent = ''{0}'' is not a valid faces-config file! -FacesConfigSelectionWizardPage_Warning_FacesConfigNotDefinedInWebDotXML = ''{0}'' is not specified in web.xml file! -FacesConfigSelectionWizardPage_HelpContextID = com.sybase.stf.jmt.select_facesconfig_page - -FacesConfigFileSelectionDialog_Title = Faces-config File Selection -FacesConfigFileSelectionDialog_Description = Select a faces-config file in the current project. - -JavaSelectionWizardPage_Title = Java Class Selection -JavaSelectionWizardPage_Description = Search for an existing class or generate a new one. -JavaSelectionWizardPage_Group = Source type for Java class -JavaSelectionWizardPage_Search = Using an existing Java class -JavaSelectionWizardPage_Search_Description = (This option will use an existing java class as managed bean's type.) -JavaSelectionWizardPage_Search_ClassName = Qualified class name: -JavaSelectionWizardPage_Search_ClassName_Browse = Browse... -JavaSelectionWizardPage_Create = Create a new Java class -JavaSelectionWizardPage_Create_Description = (This option will create a new java class in the next wizard page.) - -JavaSelectionWizardPage_FindType = Find Type -JavaSelectionWizardPage_FindType_Filter = Choose a type (?=any character, *=any string): -JavaSelectionWizardPage_Error_ClassIsEmpty = The type name should not be empty. -JavaSelectionWizardPage_Error_ClassIsNotDefined = The type name ''{0}'' does not exist. -JavaSelectionWizardPage_HelpContextID = com.sybase.stf.jmt.new_java_managedbean_wizard - -NewJavaManagedBeanWizard_Summary_ProjectName = Project name -NewJavaManagedBeanWizard_Summary_FacesConfigFileName = Faces-Config file name -NewJavaManagedBeanWizard_Summary_TypeName = Type name -NewJavaManagedBeanWizard_Summary_PackageName = Package name -NewJavaManagedBeanWizard_Summary_SourceFolder = Source folder -NewJavaManagedBeanWizard_Summary_ManagedBeanName = Managed bean name -NewJavaManagedBeanWizard_Summary_ManagedBeanScope = Managed bean scope -NewJavaManagedBeanWizard_Summary_ClassName = Managed bean class -NewJavaManagedBeanWizard_Summary_Description = Description -NewJavaManagedBeanWizard_SummaryPage_Description = A new java managed bean will be created. - -NewJavaManagedBeanWizard_Task_CreateNewManagedBean = Creating a new managed bean -NewJavaManagedBeanWizard_Task_CreateNewJavaClass = Creating a new java class - -DuplicateBeanWizard_Title = Set Duplicated Managed Bean -DuplicateBeanPage_Title = Set duplicated managed bean -DuplicateBeanPage_Description = Overwrite the duplicated managed bean or create a new one. - -DuplicateBeanGroup_Group_Label = Duplicated Managed Bean Options -DuplicateBeanGroup_OverwriteButton_Text = Overwrite an existing managed bean using the new one - -DuplicateBeanGroup_NewButton_Text = Create a new managed bean -DuplicateBeanGroup_NewNameDialogField_Label = New managed bean name: - -DuplicateBeanGroup_Error_EmptyManagedBeanName = The managed bean name can not be empty. -DuplicateBeanGroup_Error_InvalidManagedBeanName = The managed bean name ''{0}'' contains invalid string, such as #,!. -DuplicateBeanGroup_Error_DuplicatedManagedBeanName = The managed bean name ''{0}'' is duplicated. - -WizardSummaryPage_Title_WizardSummary = Wizard Summarys -WizardSummaryPage_Summary_SummaryDesc = A new java managed bean will be created. -WizardSummaryPage_Label_Field = Field -WizardSummaryPage_Label_Value = Value - - |