Skip to content

Commit

Permalink
Implement clear cache feature (issue sopeco#57)
Browse files Browse the repository at this point in the history
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
DenisKnoepfle committed Jul 27, 2014
1 parent caa6e1e commit 6abae6f
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
Binary file added org.spotter.eclipse.ui/icons/clear-cache.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions org.spotter.eclipse.ui/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,12 @@
id="org.spotter.eclipse.ui.commands.run"
name="Run">
</command>
<command
defaultHandler="org.spotter.eclipse.ui.handlers.ClearCacheHandler"
description="Clear cache containing data retrieved from DS Service"
id="org.spotter.eclipse.ui.commands.clearCache"
name="Clear Cache">
</command>
<command
defaultHandler="org.spotter.eclipse.ui.handlers.ServiceClientSettingsHandler"
description="Open DynamicSpotter Service Client Settings"
Expand Down Expand Up @@ -362,6 +368,13 @@
style="push"
tooltip="Run selected DynamicSpotter Project">
</command>
<command
commandId="org.spotter.eclipse.ui.commands.clearCache"
icon="icons/clear-cache.png"
label="Clear Cache"
style="push"
tooltip="Clear cache containing data retrieved from DS Service">
</command>
<command
commandId="org.spotter.eclipse.ui.commands.serviceClientSettings"
icon="icons/conn-settings.png"
Expand Down
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();
}

}

0 comments on commit 6abae6f

Please sign in to comment.