/
InstallHandler.java
executable file
·41 lines (35 loc) · 1.35 KB
/
InstallHandler.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package com.dubture.composer.ui.handler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.swt.SWT;
import com.dubture.composer.core.job.DownloadJob;
import com.dubture.composer.core.job.InstallJob;
import com.dubture.composer.core.launch.PharNotFoundException;
public class InstallHandler extends ComposerHandler
{
@Override
public Object execute(ExecutionEvent event) throws ExecutionException
{
try {
init(event);
} catch (PharNotFoundException e) {
installPharDialog(event);
return null;
}
if (json == null && ask(event, "No composer.json found", "Would you like to create one?") == SWT.OK) {
//TODO: create dialog and initialize composer.json
} else {
Job job = new InstallJob(composer.getLocation().toOSString());
job.setUser(true);
job.schedule();
return null;
}
if (ask(event, "No composer.phar found", "Do you want to install composer into this project?") == SWT.OK) {
Job job = new DownloadJob(scriptProject.getProject(), "Downloading composer.phar...");
job.setUser(true);
job.schedule();
}
return null;
}
}