Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BugFix]Re-pushing other existing bound cloud applications after deleting one #13

Open
wants to merge 1 commit into
base: hw-issue-7
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package org.cloudfoundry.ide.eclipse.server.ui.internal.actions;

import org.cloudfoundry.ide.eclipse.server.core.internal.CloudFoundryPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.IServerWorkingCopy;
import org.eclipse.wst.server.ui.internal.view.servers.RemoveModuleAction;

/**
* It is a menu action responsible for deleting the cloud application
* which has been published to Cloud Foundry.
*
* <p>
* Just re-write <code>removeModules()</code> method of its super-class
* <code>RemoveModuleAction</code> to avoid publishing all the bound
* cloud applications remaining in current server instance.
*
*
*/
@SuppressWarnings("restriction")
public class RemoveCloudApplicationAction extends RemoveModuleAction {

/**
* Constructs an instance of <code>RemoveCloudApplicationAction</code>.
*
* @param shell the shell to show the dialog to confirm the deletion
* @param server the server currently holding the target module
* @param module the module instance to be removed
*/
public RemoveCloudApplicationAction(Shell shell, IServer server, IModule module) {
super(shell, server, module);
}

protected void removeModules(final IModule[] modules) {
try {
final ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
dialog.setBlockOnOpen(false);
dialog.setCancelable(true);
IRunnableWithProgress runnable = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) {
try {
IServerWorkingCopy wc = server.createWorkingCopy();
if (monitor.isCanceled()) {
return;
}
wc.modifyModules(null, modules, monitor);
if (monitor.isCanceled()) {
return;
}
server = wc.save(true, monitor);
} catch (CoreException ce) {
logError(ce);
}
}
};
dialog.run(true, true, runnable);
} catch (Exception e) {
logError(e);
}
}

private void logError(Throwable t) {
CloudFoundryPlugin.logError(t);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.cloudfoundry.ide.eclipse.server.ui.internal.Messages;
import org.cloudfoundry.ide.eclipse.server.ui.internal.actions.DeleteServicesAction;
import org.cloudfoundry.ide.eclipse.server.ui.internal.actions.RefreshApplicationEditorAction;
import org.cloudfoundry.ide.eclipse.server.ui.internal.actions.RemoveCloudApplicationAction;
import org.cloudfoundry.ide.eclipse.server.ui.internal.actions.ServiceToApplicationsBindingAction;
import org.cloudfoundry.ide.eclipse.server.ui.internal.wizards.CloudFoundryServiceWizard;
import org.cloudfoundry.ide.eclipse.server.ui.internal.wizards.CloudRoutesWizard;
Expand Down Expand Up @@ -619,7 +620,7 @@ private void fillApplicationsContextMenu(IMenuManager manager) {

IModule module = (IModule) selection.getFirstElement();
if (module != null) {
manager.add(new RemoveModuleAction(getSection().getShell(), editorPage.getServer().getOriginal(), module));
manager.add(new RemoveCloudApplicationAction(getSection().getShell(), editorPage.getServer().getOriginal(), module));
}
}

Expand Down