forked from sopeco/DynamicSpotter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement clear cache feature (issue sopeco#57)
Implemented the feature and made it available in the context menu when at least one project is selected. Currently there is a bug when right-clicking on the project which has not been selected before. This problem is addressed in sopeco#63. Change-Id: Ic4c9cc663c06f9d49532f370789dbd762c3d8789 Signed-off-by: Denis Knoepfle <[email protected]>
- Loading branch information
1 parent
caa6e1e
commit 6abae6f
Showing
3 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
org.spotter.eclipse.ui/src/org/spotter/eclipse/ui/handlers/ClearCacheHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* Copyright 2014 SAP AG | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.spotter.eclipse.ui.handlers; | ||
|
||
import org.eclipse.core.commands.AbstractHandler; | ||
import org.eclipse.core.commands.ExecutionEvent; | ||
import org.eclipse.core.commands.ExecutionException; | ||
import org.eclipse.core.resources.IProject; | ||
import org.spotter.eclipse.ui.Activator; | ||
import org.spotter.eclipse.ui.util.DialogUtils; | ||
|
||
/** | ||
* A handler for the clear cache command which clears the cache containing data | ||
* retrieved from the DS service. | ||
* | ||
* @author Denis Knoepfle | ||
* | ||
*/ | ||
public class ClearCacheHandler extends AbstractHandler { | ||
|
||
/** | ||
* The id of the corresponding clear cache command. | ||
*/ | ||
public static final String CLEAR_CACHE_COMMAND_ID = "org.spotter.eclipse.ui.commands.clearCache"; | ||
|
||
@Override | ||
public Object execute(ExecutionEvent event) throws ExecutionException { | ||
Activator activator = Activator.getDefault(); | ||
for (IProject project : activator.getSelectedProjects()) { | ||
String projectName = project.getName(); | ||
activator.getClient(projectName).clearCache(); | ||
} | ||
|
||
DialogUtils.openInformation("This feature is not fully implemented yet and only " | ||
+ "clears the extensions cache without checking if any open " | ||
+ "editors/views are still in a valid state in case the extensions have " | ||
+ "changed on the server side."); | ||
|
||
return null; | ||
} | ||
|
||
@Override | ||
public boolean isEnabled() { | ||
return !Activator.getDefault().getSelectedProjects().isEmpty(); | ||
} | ||
|
||
} |