creatorextension/com.nokia.s60tools.creator/src/com/nokia/s60tools/creator/dialogs/DialogLauncher.java
author dpodwall
Tue, 12 Jan 2010 13:17:53 -0600
changeset 0 61163b28edca
permissions -rw-r--r--
initial EPL conversion
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     1
/*
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     2
* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     3
* All rights reserved.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     4
* This component and the accompanying materials are made available
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     6
* which accompanies this distribution, and is available
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     8
*
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     9
* Initial Contributors:
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    11
*
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    12
* Contributors:
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    13
*
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    14
* Description:
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    15
*
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    16
*/
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    17
 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    18
package com.nokia.s60tools.creator.dialogs;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    19
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    20
import org.eclipse.swt.widgets.Shell;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    21
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    22
import com.nokia.s60tools.creator.components.calendar.CalendarVariables;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    23
import com.nokia.s60tools.creator.components.messaging.MessageVariables;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    24
import com.nokia.s60tools.creator.core.CreatorEditorSettings;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    25
import com.nokia.s60tools.creator.editors.IComponentProvider;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    26
import com.nokia.s60tools.creator.util.CreatorEditorConsole;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    27
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    28
/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    29
 * Helper class to found correct real implementing Dialog class
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    30
 * for {@link AbstractDialog} by selected component type
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    31
 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    32
public class DialogLauncher {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    33
	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    34
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    35
	 * Get dialog by component type. Used when Add dialog is launched.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    36
	 * @param componentType
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    37
	 * @param sh
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    38
	 * @return aDialog
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    39
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    40
	public static AbstractDialog getDialog(String componentType, Shell sh, final IComponentProvider provider) 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    41
	{
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    42
		
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    43
		if(componentType.equals(CreatorEditorSettings.TYPE_CONTACT)){
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    44
			return new ContactDialog(sh, provider);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    45
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    46
		else if(componentType.equals(CreatorEditorSettings.TYPE_CONTACT_SET)){
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    47
			return new ContactSetDialog(sh, provider);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    48
		}		
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    49
		else if(componentType.equals(CreatorEditorSettings.TYPE_CONTACT_GROUP)){
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    50
			return new ContactGroupDialog(sh, provider);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    51
		}		
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    52
		else if(componentType.equals(CreatorEditorSettings.TYPE_NOTE)){
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    53
			return new NoteDialog(sh, provider);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    54
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    55
		else if(componentType.equals(CreatorEditorSettings.TYPE_BOOKMARK)){
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    56
			return new BookmarkDialog(sh, provider);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    57
		}			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    58
		else if(componentType.equals(CreatorEditorSettings.TYPE_BOOKMARK_FOLDER)){
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    59
			return new BookmarkFolderDialog(sh, provider);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    60
		}	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    61
		else if(componentType.equals(CreatorEditorSettings.TYPE_SAVED_PAGE)){
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    62
			return new SavedPageDialog(sh, provider);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    63
		}			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    64
		else if(componentType.equals(CreatorEditorSettings.TYPE_SAVED_PAGE_FOLDER)){
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    65
			return new SavedPageFolderDialog(sh, provider);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    66
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    67
		else if(componentType.equals(CreatorEditorSettings.TYPE_LOG)){
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    68
			return new LogDialog(sh, provider);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    69
		}		
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    70
		else if(componentType.equals(CreatorEditorSettings.TYPE_IMPS_SERVER)){
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    71
			return new IMPSServerDialog(sh, provider);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    72
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    73
		else if(componentType.equals(CreatorEditorSettings.TYPE_CONNECTION_METHOD)){
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    74
			return new ConnectionMethodDialog(sh, provider);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    75
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    76
		else if(
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    77
				componentType.equals(CreatorEditorSettings.TYPE_TODO)
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    78
				|| componentType.equals(CreatorEditorSettings.TYPE_APPOINTMENT)
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    79
				|| componentType.equals(CreatorEditorSettings.TYPE_EVENT)
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    80
				|| componentType.equals(CreatorEditorSettings.TYPE_REMINDER)
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    81
				|| componentType.equals(CreatorEditorSettings.TYPE_ANNIVERSARY)				
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    82
		){
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    83
			return new CalendarDialog(sh, 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    84
					CalendarVariables.getInstance().getIdByValue(componentType), provider);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    85
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    86
		else if(
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    87
				componentType.equals(CreatorEditorSettings.TYPE_MESSAGE_SMS)
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    88
				|| componentType.equals(CreatorEditorSettings.TYPE_MESSAGE_MMS)
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    89
				|| componentType.equals(CreatorEditorSettings.TYPE_MESSAGE_AMS)
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    90
				|| componentType.equals(CreatorEditorSettings.TYPE_MESSAGE_EMAIL)
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    91
				|| componentType.equals(CreatorEditorSettings.TYPE_MESSAGE_SMART)
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    92
				|| componentType.equals(CreatorEditorSettings.TYPE_MESSAGE_IR)				
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    93
				|| componentType.equals(CreatorEditorSettings.TYPE_MESSAGE_BT)
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    94
		){
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    95
			return new MessageDialog(sh, 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    96
					MessageVariables.getInstance().getIdByValue(componentType), provider);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    97
		}		
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    98
		else if(componentType.equals(CreatorEditorSettings.TYPE_MAIL_BOX)){
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    99
			return new MailBoxDialog(sh, provider);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   100
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   101
		else if(componentType.equals(CreatorEditorSettings.TYPE_LANDMARK)){
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   102
			return new LandmarkDialog(sh, provider);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   103
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   104
		else if(componentType.equals(CreatorEditorSettings.TYPE_FILE)){
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   105
			return new FileTypeDialog(sh, provider);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   106
		}			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   107
		else{
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   108
			CreatorEditorConsole.getInstance().println("Unknown dialog type: " + componentType, CreatorEditorConsole.MSG_ERROR);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   109
			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   110
			return null;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   111
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   112
		
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   113
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   114
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   115
	 * Get dialog by component. Used when Edit dialog is launched.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   116
	 * @param component
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   117
	 * @param sh
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   118
	 * @return aDialog
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   119
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   120
	public static AbstractDialog getDialog(final IComponentProvider provider, Shell sh) 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   121
	{		
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   122
		
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   123
		if(provider.getEditable().getType().equals(CreatorEditorSettings.TYPE_CONTACT)){
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   124
			return new ContactDialog(sh, provider);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   125
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   126
		else if(provider.getEditable().getType().equals(CreatorEditorSettings.TYPE_CONTACT_SET)){
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   127
			return new ContactSetDialog(sh, provider);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   128
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   129
		else if(provider.getEditable().getType().equals(CreatorEditorSettings.TYPE_CONTACT_GROUP)){
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   130
			return new ContactGroupDialog(sh, provider);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   131
		}				
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   132
		else if(provider.getEditable().getType().equals(CreatorEditorSettings.TYPE_NOTE)){
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   133
			return new NoteDialog(sh, provider);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   134
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   135
		else if(provider.getEditable().getType().equals(CreatorEditorSettings.TYPE_BOOKMARK)){
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   136
			return new BookmarkDialog(sh, provider);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   137
		}			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   138
		else if(provider.getEditable().getType().equals(CreatorEditorSettings.TYPE_BOOKMARK_FOLDER)){
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   139
			return new BookmarkFolderDialog(sh, provider);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   140
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   141
		else if(provider.getEditable().getType().equals(CreatorEditorSettings.TYPE_SAVED_PAGE)){
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   142
			return new SavedPageDialog(sh, provider);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   143
		}			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   144
		else if(provider.getEditable().getType().equals(CreatorEditorSettings.TYPE_SAVED_PAGE_FOLDER)){
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   145
			return new SavedPageFolderDialog(sh, provider);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   146
		}			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   147
		else if(provider.getEditable().getType().equals(CreatorEditorSettings.TYPE_LOG)){
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   148
			return new LogDialog(sh, provider);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   149
		}			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   150
		else if(provider.getEditable().getType().equals(CreatorEditorSettings.TYPE_IMPS_SERVER)){
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   151
			return new IMPSServerDialog(sh, provider);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   152
		}	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   153
		else if(provider.getEditable().getType().equals(CreatorEditorSettings.TYPE_CONNECTION_METHOD)){
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   154
			return new ConnectionMethodDialog(sh, provider);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   155
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   156
		else if(provider.getEditable().getType().equals(CreatorEditorSettings.TYPE_CALENDAR)){
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   157
			return new CalendarDialog(sh, provider); 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   158
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   159
		else if(provider.getEditable().getType().equals(CreatorEditorSettings.TYPE_MESSAGE)){
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   160
			return new MessageDialog(sh, provider); 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   161
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   162
		else if(provider.getEditable().getType().equals(CreatorEditorSettings.TYPE_MAIL_BOX)){
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   163
			return new MailBoxDialog(sh, provider);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   164
		}	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   165
		else if(provider.getEditable().getType().equals(CreatorEditorSettings.TYPE_LANDMARK)){
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   166
			return new LandmarkDialog(sh, provider);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   167
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   168
		else if(provider.getEditable().getType().equals(CreatorEditorSettings.TYPE_FILE)){
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   169
			return new FileTypeDialog(sh, provider);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   170
		}			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   171
		else{
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   172
			CreatorEditorConsole.getInstance().println("Unknown dialog type: " + provider.getEditable().getType(), CreatorEditorConsole.MSG_ERROR);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   173
			return null;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   174
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   175
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   176
	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   177
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   178
}