0
|
1 |
/*
|
|
2 |
* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
package com.nokia.s60tools.appdep.ui.actions;
|
|
20 |
|
|
21 |
import org.eclipse.swt.SWT;
|
|
22 |
|
|
23 |
import com.nokia.s60tools.appdep.core.AppDepSettings;
|
|
24 |
import com.nokia.s60tools.appdep.core.job.GenerateCacheJob;
|
|
25 |
import com.nokia.s60tools.appdep.resources.ImageKeys;
|
|
26 |
import com.nokia.s60tools.appdep.resources.ImageResourceManager;
|
|
27 |
import com.nokia.s60tools.appdep.resources.Messages;
|
|
28 |
import com.nokia.s60tools.appdep.ui.dialogs.AppDepMessageBox;
|
|
29 |
import com.nokia.s60tools.appdep.ui.views.main.MainView;
|
|
30 |
|
|
31 |
/**
|
|
32 |
* Start cache update if needed from main view's toolbar.
|
|
33 |
*/
|
|
34 |
public class CacheUpdateMainViewAction extends AbstractMainViewAction {
|
|
35 |
|
|
36 |
public static final String ACTION_ID = "com.nokia.s60tools.appdep.ui.actions.CacheUpdateMainViewAction"; //$NON-NLS-1$
|
|
37 |
|
|
38 |
/**
|
|
39 |
* Constructor.
|
|
40 |
* @param view Reference to the view.
|
|
41 |
*/
|
|
42 |
public CacheUpdateMainViewAction(MainView view){
|
|
43 |
super(view);
|
|
44 |
setText(Messages.getString("CacheUpdateMainViewAction.CacheUpdateMainView_Action_Text")); //$NON-NLS-1$
|
|
45 |
setToolTipText(Messages.getString("CacheUpdateMainViewAction.CacheUpdateMainView_Action_Tooltip")); //$NON-NLS-1$
|
|
46 |
|
|
47 |
setId(ACTION_ID);
|
|
48 |
setImageDescriptor(ImageResourceManager.
|
|
49 |
getImageDescriptor(ImageKeys.CACHE_UPDATE_ACTION));
|
|
50 |
|
|
51 |
}
|
|
52 |
|
|
53 |
/* (non-Javadoc)
|
|
54 |
* @see org.eclipse.jface.action.IAction#run()
|
|
55 |
*/
|
|
56 |
public void run() {
|
|
57 |
|
|
58 |
String currentRootComponent = null;
|
|
59 |
AppDepSettings activeSettings = AppDepSettings.getActiveSettings();
|
|
60 |
currentRootComponent = activeSettings.getCurrentlyAnalyzedComponentName();
|
|
61 |
|
|
62 |
if(currentRootComponent == null){
|
|
63 |
// User has not selected any components for analysis
|
|
64 |
String infoMsg = Messages.getString("GeneralMessages.Select_SDK_First_ErrMsg"); //$NON-NLS-1$
|
|
65 |
new AppDepMessageBox(infoMsg, SWT.OK | SWT.ICON_INFORMATION).open();
|
|
66 |
return;
|
|
67 |
}
|
|
68 |
|
|
69 |
if(activeSettings.currentlySelectedCachesNeedsUpdate()){
|
|
70 |
// Aborting possible ongoing search
|
|
71 |
MainView.abortCurrentlyOngoingSearches();
|
|
72 |
|
|
73 |
// Triggering cache generation job
|
|
74 |
GenerateCacheJob.triggerCacheGenerationForCurrentlyActiveSettings();
|
|
75 |
}
|
|
76 |
else{
|
|
77 |
// Cache is up-to-date
|
|
78 |
String infoMsg = null;
|
|
79 |
if(activeSettings.getCurrentlyUsedTargetPlatforms().length > 1){
|
|
80 |
infoMsg = Messages.getString("CacheUpdateMainViewAction.Caches_Are_Up_To_Date_InfoMsg"); //$NON-NLS-1$
|
|
81 |
}
|
|
82 |
else{
|
|
83 |
infoMsg = Messages.getString("CacheUpdateMainViewAction.Cache_Is_Up_To_Date_InfoMsg"); //$NON-NLS-1$
|
|
84 |
}
|
|
85 |
new AppDepMessageBox(infoMsg, SWT.OK | SWT.ICON_INFORMATION).open();
|
|
86 |
return;
|
|
87 |
}
|
|
88 |
|
|
89 |
// Remember to always call AbstractMainViewAction
|
|
90 |
// base class implementation
|
|
91 |
super.run();
|
|
92 |
|
|
93 |
}
|
|
94 |
|
|
95 |
}
|