private void addToolStripMenuItem_Click(object sender, EventArgs e)
{
if (openFileDialogJar.ShowDialog(this) == DialogResult.OK) {
AemInstance instance = new AemInstance();
// auto-detect some instance properties
instance.Path = openFileDialogJar.FileName;
string[] pathParts = instance.Path.Split('/', '\\');
string jarFilename = pathParts[pathParts.Length-1];
if (jarFilename.Contains("-publish") || instance.Path.Contains("/publish/")) {
instance.Runmode = Runmode.PUBLISH;
}
else {
instance.Runmode = Runmode.AUTHOR;
}
string[] fileParts = jarFilename.Split('-','.');
foreach (string filePart in fileParts) {
int port = 0;
if (int.TryParse(filePart, out port)) {
instance.Port = port;
}
}
if (pathParts.Length > 4) {
string name = pathParts[pathParts.Length - 2];
if ("author".Equals(name) || "publish".Equals(name)) {
name = pathParts[pathParts.Length - 3];
}
instance.Name = name;
}
AemInstanceDialog dialog = new AemInstanceDialog(instance);
if (dialog.ShowDialog(this) == DialogResult.OK) {
instance.Save();
Program.InstanceList.Add(instance);
Program.InstanceList.SortByName();
Program.UpdateInstanceListInViews();
}
}
}