X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.project%2Fsrc%2Forg%2Fsimantics%2Fproject%2Fmanagement%2Finstall%2FSWTInstallAdvisor.java;fp=bundles%2Forg.simantics.project%2Fsrc%2Forg%2Fsimantics%2Fproject%2Fmanagement%2Finstall%2FSWTInstallAdvisor.java;h=88e4e7a53a37748c6ead34deced129635d7219a3;hp=2aec7ae4614228722793d4fe76dfd1530d336048;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.project/src/org/simantics/project/management/install/SWTInstallAdvisor.java b/bundles/org.simantics.project/src/org/simantics/project/management/install/SWTInstallAdvisor.java index 2aec7ae46..88e4e7a53 100644 --- a/bundles/org.simantics.project/src/org/simantics/project/management/install/SWTInstallAdvisor.java +++ b/bundles/org.simantics.project/src/org/simantics/project/management/install/SWTInstallAdvisor.java @@ -1,82 +1,82 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.simantics.project.management.install; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.equinox.internal.provisional.p2.installer.IInstallOperation; -import org.eclipse.equinox.internal.provisional.p2.installer.InstallAdvisor; -import org.eclipse.equinox.internal.provisional.p2.installer.InstallDescription; -import org.eclipse.swt.widgets.Display; - -/** - * Install context that creates a simple SWT-based UI and interacts with a user. - */ -public class SWTInstallAdvisor extends InstallAdvisor { - private InstallDialog dialog; - private boolean started = false; - private boolean stopped = false; - - public IStatus performInstall(IInstallOperation operation) { - return dialog.run(operation); - } - - public InstallDescription prepareInstallDescription(InstallDescription description) { - if (description.getInstallLocation() == null) - dialog.promptForLocations(description); - return description; - } - - public boolean promptForLaunch(InstallDescription description) { - return dialog.promptForLaunch(description); - } - - public void setResult(IStatus status) { - String message; - if (status.getSeverity() == IStatus.CANCEL) { - message = "Canceled"; - } else { - message = status.getMessage(); - } - dialog.promptForClose(message); - } - - public synchronized void start() { - if (stopped || started) - return; - started = true; - Display display = Display.getCurrent(); - if (display == null) - display = new Display(); - dialog = new InstallDialog(); - dialog.setMessage("Preparing"); - } - - public synchronized void stop() { - if (stopped || !started) - return; - stopped = true; - final InstallDialog activeDialog = dialog; - if (activeDialog == null) - return; - //clear the window now, so the reference is gone no matter what happens during cleanup - dialog = null; - final Display display = activeDialog.getDisplay(); - if (display == null || display.isDisposed()) - return; - display.syncExec(new Runnable() { - public void run() { - activeDialog.close(); - } - }); - display.dispose(); - } - -} +/******************************************************************************* + * Copyright (c) 2007, 2008 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.simantics.project.management.install; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.equinox.internal.provisional.p2.installer.IInstallOperation; +import org.eclipse.equinox.internal.provisional.p2.installer.InstallAdvisor; +import org.eclipse.equinox.internal.provisional.p2.installer.InstallDescription; +import org.eclipse.swt.widgets.Display; + +/** + * Install context that creates a simple SWT-based UI and interacts with a user. + */ +public class SWTInstallAdvisor extends InstallAdvisor { + private InstallDialog dialog; + private boolean started = false; + private boolean stopped = false; + + public IStatus performInstall(IInstallOperation operation) { + return dialog.run(operation); + } + + public InstallDescription prepareInstallDescription(InstallDescription description) { + if (description.getInstallLocation() == null) + dialog.promptForLocations(description); + return description; + } + + public boolean promptForLaunch(InstallDescription description) { + return dialog.promptForLaunch(description); + } + + public void setResult(IStatus status) { + String message; + if (status.getSeverity() == IStatus.CANCEL) { + message = "Canceled"; + } else { + message = status.getMessage(); + } + dialog.promptForClose(message); + } + + public synchronized void start() { + if (stopped || started) + return; + started = true; + Display display = Display.getCurrent(); + if (display == null) + display = new Display(); + dialog = new InstallDialog(); + dialog.setMessage("Preparing"); + } + + public synchronized void stop() { + if (stopped || !started) + return; + stopped = true; + final InstallDialog activeDialog = dialog; + if (activeDialog == null) + return; + //clear the window now, so the reference is gone no matter what happens during cleanup + dialog = null; + final Display display = activeDialog.getDisplay(); + if (display == null || display.isDisposed()) + return; + display.syncExec(new Runnable() { + public void run() { + activeDialog.close(); + } + }); + display.dispose(); + } + +}