1 /* 2 * Copyright (C) 2012 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.motorola.studio.android.installer.handlers; 17 18 import org.eclipse.core.commands.ExecutionEvent; 19 import org.eclipse.core.commands.ExecutionException; 20 import org.eclipse.core.commands.IHandler; 21 import org.eclipse.core.commands.IHandlerListener; 22 import org.eclipse.core.runtime.jobs.Job; 23 24 import com.motorola.studio.android.common.utilities.EclipseUtils; 25 import com.motorola.studio.android.installer.i18n.InstallerNLS; 26 import com.motorola.studio.android.installer.jobs.UpdateStudioJob; 27 28 public class UpdateStudioHandler implements IHandler 29 { 30 31 public void addHandlerListener(IHandlerListener handlerListener) 32 { 33 // Nothing to do 34 35 } 36 37 public void dispose() 38 { 39 // Nothing to do 40 41 } 42 43 public Object execute(ExecutionEvent event) throws ExecutionException 44 { 45 46 Job progressJob = UpdateStudioJob.getInstance(); 47 48 if ((progressJob != null) 49 && ((progressJob.getState() == Job.WAITING) || (progressJob.getState() == Job.RUNNING))) 50 { 51 EclipseUtils.showInformationDialog(InstallerNLS.UpdateStudio_UpdateAlreadyRunningTitle, 52 InstallerNLS.UpdateStudio_UpdateAlreadyRunningMsg); 53 } 54 else 55 { 56 progressJob = 57 UpdateStudioJob 58 .createJob(InstallerNLS.UpdateStudio_CheckingForUpdatesJobDescription); 59 progressJob.setUser(true); 60 progressJob.schedule(); 61 } 62 63 return null; 64 } 65 66 public boolean isEnabled() 67 { 68 69 return true; 70 } 71 72 public boolean isHandled() 73 { 74 75 return true; 76 } 77 78 public void removeHandlerListener(IHandlerListener handlerListener) 79 { 80 // Nothing to do 81 } 82 83 } 84