|
1 | 1 | /******************************************************************************* |
2 | | - * Copyright (c) 2018 IBM Corporation and others. |
| 2 | + * Copyright (c) 2018, 2019 IBM Corporation and others. |
3 | 3 | * All rights reserved. This program and the accompanying materials |
4 | 4 | * are made available under the terms of the Eclipse Public License v2.0 |
5 | 5 | * which accompanies this distribution, and is available at |
|
11 | 11 |
|
12 | 12 | package com.ibm.microclimate.ui.internal.actions; |
13 | 13 |
|
| 14 | +import org.eclipse.core.runtime.IProgressMonitor; |
| 15 | +import org.eclipse.core.runtime.IStatus; |
| 16 | +import org.eclipse.core.runtime.Status; |
| 17 | +import org.eclipse.core.runtime.jobs.Job; |
14 | 18 | import org.eclipse.jface.action.IAction; |
15 | 19 | import org.eclipse.jface.viewers.ISelection; |
16 | 20 | import org.eclipse.jface.viewers.IStructuredSelection; |
| 21 | +import org.eclipse.osgi.util.NLS; |
17 | 22 | import org.eclipse.ui.IObjectActionDelegate; |
18 | 23 | import org.eclipse.ui.IWorkbenchPart; |
19 | 24 |
|
20 | 25 | import com.ibm.microclimate.core.internal.MCLogger; |
21 | 26 | import com.ibm.microclimate.core.internal.MicroclimateApplication; |
22 | 27 | import com.ibm.microclimate.core.internal.connection.MicroclimateConnection; |
| 28 | +import com.ibm.microclimate.ui.internal.messages.Messages; |
23 | 29 | import com.ibm.microclimate.ui.internal.views.ViewHelper; |
24 | 30 |
|
25 | 31 | /** |
@@ -52,13 +58,27 @@ public void selectionChanged(IAction action, ISelection selection) { |
52 | 58 | @Override |
53 | 59 | public void run(IAction action) { |
54 | 60 | if (microclimateObject instanceof MicroclimateConnection) { |
55 | | - MicroclimateConnection connection = (MicroclimateConnection) microclimateObject; |
56 | | - connection.refreshApps(null); |
57 | | - ViewHelper.refreshMicroclimateExplorerView(connection); |
| 61 | + final MicroclimateConnection connection = (MicroclimateConnection) microclimateObject; |
| 62 | + Job job = new Job(NLS.bind(Messages.RefreshConnectionJobLabel, connection.baseUrl.toString())) { |
| 63 | + @Override |
| 64 | + protected IStatus run(IProgressMonitor monitor) { |
| 65 | + connection.refreshApps(null); |
| 66 | + ViewHelper.refreshMicroclimateExplorerView(connection); |
| 67 | + return Status.OK_STATUS; |
| 68 | + } |
| 69 | + }; |
| 70 | + job.schedule(); |
58 | 71 | } else if (microclimateObject instanceof MicroclimateApplication) { |
59 | | - MicroclimateApplication app = (MicroclimateApplication) microclimateObject; |
60 | | - app.mcConnection.refreshApps(app.projectID); |
61 | | - ViewHelper.refreshMicroclimateExplorerView(app); |
| 72 | + final MicroclimateApplication app = (MicroclimateApplication) microclimateObject; |
| 73 | + Job job = new Job(NLS.bind(Messages.RefreshProjectJobLabel, app.name)) { |
| 74 | + @Override |
| 75 | + protected IStatus run(IProgressMonitor monitor) { |
| 76 | + app.mcConnection.refreshApps(app.projectID); |
| 77 | + ViewHelper.refreshMicroclimateExplorerView(app); |
| 78 | + return Status.OK_STATUS; |
| 79 | + } |
| 80 | + }; |
| 81 | + job.schedule(); |
62 | 82 | } else { |
63 | 83 | // Should not happen |
64 | 84 | MCLogger.logError("RefreshAction ran but no Microclimate object was selected"); |
|
0 commit comments