-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
321 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
JazminDeployer/src/jazmin/deploy/view/console/ConsoleView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package jazmin.deploy.view.console; | ||
|
||
import com.vaadin.ui.Component; | ||
import com.vaadin.ui.TabSheet; | ||
import com.vaadin.ui.VerticalLayout; | ||
/** | ||
* | ||
* @author yama | ||
* 30 Dec, 2014 | ||
*/ | ||
@SuppressWarnings("serial") | ||
public class ConsoleView extends VerticalLayout { | ||
private TabSheet tabsheet; | ||
public ConsoleView() { | ||
setSizeFull(); | ||
tabsheet=new TabSheet(); | ||
tabsheet.setSizeFull(); | ||
addComponent(tabsheet); | ||
setExpandRatio(tabsheet, 1); | ||
// | ||
tabsheet.addComponent(new MachineOptView()); | ||
tabsheet.addComponent(new InstanceOptView()); | ||
} | ||
// | ||
public void addOptView(Component component){ | ||
tabsheet.addComponent(component); | ||
tabsheet.setSelectedTab(component); | ||
tabsheet.getTab(component).setClosable(true); | ||
|
||
} | ||
} |
173 changes: 173 additions & 0 deletions
173
JazminDeployer/src/jazmin/deploy/view/console/InstanceOptView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
/** | ||
* | ||
*/ | ||
package jazmin.deploy.view.console; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import jazmin.deploy.DeploySystemUI; | ||
import jazmin.deploy.domain.Application; | ||
import jazmin.deploy.domain.DeployManager; | ||
import jazmin.deploy.domain.Instance; | ||
import jazmin.deploy.ui.BeanTable; | ||
import jazmin.deploy.view.instance.InstanceHaproxyStatWindow; | ||
import jazmin.deploy.view.instance.InstanceMemcachedWindow; | ||
import jazmin.deploy.view.instance.InstanceMySQLWindow; | ||
import jazmin.deploy.view.instance.InstanceWebSshWindow; | ||
import jazmin.deploy.view.main.DeployBaseView; | ||
|
||
import com.vaadin.event.ItemClickEvent; | ||
import com.vaadin.event.ItemClickEvent.ItemClickListener; | ||
import com.vaadin.event.ShortcutAction.KeyCode; | ||
import com.vaadin.event.ShortcutListener; | ||
import com.vaadin.server.FontAwesome; | ||
import com.vaadin.ui.Alignment; | ||
import com.vaadin.ui.Button; | ||
import com.vaadin.ui.Component; | ||
import com.vaadin.ui.HorizontalLayout; | ||
import com.vaadin.ui.Label; | ||
import com.vaadin.ui.TextField; | ||
import com.vaadin.ui.Window; | ||
import com.vaadin.ui.themes.ValoTheme; | ||
|
||
/** | ||
* @author yama | ||
* 6 Jan, 2015 | ||
*/ | ||
@SuppressWarnings("serial") | ||
public class InstanceOptView extends DeployBaseView{ | ||
BeanTable<Instance>table; | ||
List<Instance>instanceList; | ||
// | ||
public InstanceOptView() { | ||
super(); | ||
setCaption("Instances"); | ||
searchTxt.setValue("1=1 order by priority desc"); | ||
loadData(); | ||
} | ||
// | ||
protected void initBaseUI(){ | ||
setSizeFull(); | ||
// | ||
HorizontalLayout optLayout = new HorizontalLayout(); | ||
optLayout.setSpacing(true); | ||
optLayout.addStyleName(ValoTheme.WINDOW_TOP_TOOLBAR); | ||
optLayout.setWidth(100.0f, Unit.PERCENTAGE); | ||
searchTxt = new TextField("Filter", ""); | ||
searchTxt.setIcon(FontAwesome.SEARCH); | ||
searchTxt.setWidth(100.0f, Unit.PERCENTAGE); | ||
searchTxt.addStyleName(ValoTheme.TEXTFIELD_TINY); | ||
searchTxt.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON); | ||
searchTxt.addShortcutListener(new ShortcutListener("Search",KeyCode.ENTER,null) { | ||
@Override | ||
public void handleAction(Object sender, Object target) { | ||
loadData(); | ||
} | ||
}); | ||
// | ||
optLayout.addComponent(searchTxt); | ||
optLayout.setExpandRatio(searchTxt,1.0f); | ||
// | ||
Button ok = new Button("Query"); | ||
ok.addStyleName(ValoTheme.BUTTON_PRIMARY); | ||
ok.addStyleName(ValoTheme.BUTTON_SMALL); | ||
optLayout.addComponent(ok); | ||
ok.addClickListener(e->loadData()); | ||
optLayout.setComponentAlignment(ok, Alignment.BOTTOM_RIGHT); | ||
|
||
// | ||
addComponent(optLayout); | ||
|
||
BeanTable<?> table = createTable(); | ||
addComponent(table); | ||
table.setSizeFull(); | ||
setExpandRatio(table, 1); | ||
tray = new HorizontalLayout(); | ||
tray.setWidth(100.0f, Unit.PERCENTAGE); | ||
tray.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); | ||
tray.setSpacing(true); | ||
tray.setMargin(true); | ||
// | ||
Label emptyLabel=new Label(""); | ||
tray.addComponent(emptyLabel); | ||
tray.setComponentAlignment(emptyLabel, Alignment.MIDDLE_RIGHT); | ||
tray.setExpandRatio(emptyLabel,1.0f); | ||
// | ||
addComponent(tray); | ||
} | ||
// | ||
@Override | ||
public BeanTable<?> createTable() { | ||
instanceList=new ArrayList<Instance>(); | ||
table= new BeanTable<Instance>(null, Instance.class, | ||
"machine","user","password","application","properties"); | ||
table.addItemClickListener(new ItemClickListener() { | ||
@Override | ||
public void itemClick(ItemClickEvent event) { | ||
if(event.isDoubleClick()){ | ||
Instance instance=table.getItemValue(event.getItem()); | ||
openConsole(instance); | ||
} | ||
} | ||
}); | ||
return table; | ||
} | ||
// | ||
private void openConsole(Instance instance){ | ||
if(instance.application==null){ | ||
DeploySystemUI.showNotificationInfo("Info", | ||
"Can not find application on instance:"+instance.id); | ||
return; | ||
} | ||
Window window=null; | ||
// | ||
if(instance.application.type.equals(Application.TYPE_HAPROXY)){ | ||
window=new InstanceHaproxyStatWindow(instance); | ||
} | ||
// | ||
if(instance.application.type.equals(Application.TYPE_MYSQL)){ | ||
window=new InstanceMySQLWindow(instance); | ||
} | ||
// | ||
if(instance.application.type.equals(Application.TYPE_MEMCACHED)){ | ||
window=new InstanceMemcachedWindow(instance); | ||
|
||
} | ||
// | ||
if(instance.application.type.startsWith("jazmin")){ | ||
window=new InstanceWebSshWindow(instance); | ||
|
||
} | ||
if(window!=null){ | ||
Component c=window.getContent(); | ||
c.setCaption(window.getCaption()); | ||
DeploySystemUI.get().getMainView().getConsoleView().addOptView(c); | ||
}else{ | ||
DeploySystemUI.showNotificationInfo("Info", | ||
"Not support application type:"+instance.application.type); | ||
} | ||
} | ||
// | ||
@Override | ||
public void loadData(){ | ||
String search=getSearchValue(); | ||
if(search==null){ | ||
return; | ||
} | ||
try { | ||
instanceList=DeployManager.getInstances(search); | ||
if(instanceList.isEmpty()){ | ||
DeploySystemUI.showNotificationInfo("Result","No mactch result found."); | ||
} | ||
table.setData(instanceList); | ||
} catch (Throwable e1) { | ||
DeploySystemUI.showNotificationInfo("Error",e1.getMessage()); | ||
} | ||
} | ||
// | ||
public List<Instance>getOptInstances(){ | ||
return instanceList; | ||
} | ||
|
||
} |
76 changes: 76 additions & 0 deletions
76
JazminDeployer/src/jazmin/deploy/view/console/MachineOptView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/** | ||
* | ||
*/ | ||
package jazmin.deploy.view.console; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import jazmin.deploy.DeploySystemUI; | ||
import jazmin.deploy.domain.DeployManager; | ||
import jazmin.deploy.domain.Machine; | ||
import jazmin.deploy.ui.BeanTable; | ||
import jazmin.deploy.view.machine.MachineWebSshWindow; | ||
import jazmin.deploy.view.main.DeployBaseView; | ||
|
||
import com.vaadin.event.ItemClickEvent; | ||
import com.vaadin.event.ItemClickEvent.ItemClickListener; | ||
import com.vaadin.ui.Component; | ||
|
||
/** | ||
* @author yama | ||
* 6 Jan, 2015 | ||
*/ | ||
@SuppressWarnings("serial") | ||
public class MachineOptView extends DeployBaseView{ | ||
BeanTable<Machine>table; | ||
private List<Machine>machines; | ||
// | ||
public MachineOptView() { | ||
super(); | ||
setCaption("Machines"); | ||
searchTxt.setValue("1=1"); | ||
setSizeFull(); | ||
loadData(); | ||
} | ||
@Override | ||
public BeanTable<?> createTable() { | ||
machines=new ArrayList<Machine>(); | ||
table= new BeanTable<Machine>(null, Machine.class, | ||
"sshPassword", | ||
"rootSshPassword", | ||
"jazminHome", | ||
"memcachedHome", | ||
"haproxyHome"); | ||
table.addItemClickListener(new ItemClickListener() { | ||
@Override | ||
public void itemClick(ItemClickEvent event) { | ||
if(event.isDoubleClick()){ | ||
Machine machine=table.getItemValue(event.getItem()); | ||
MachineWebSshWindow window=new MachineWebSshWindow(machine); | ||
Component c=window.getContent(); | ||
c.setCaption(window.getCaption()); | ||
DeploySystemUI.get().getMainView().getConsoleView().addOptView(c); | ||
} | ||
} | ||
}); | ||
return table; | ||
} | ||
// | ||
@Override | ||
public void loadData(){ | ||
String search=getSearchValue(); | ||
if(search==null){ | ||
return; | ||
} | ||
try { | ||
machines=DeployManager.getMachines(search); | ||
if(machines.isEmpty()){ | ||
DeploySystemUI.showNotificationInfo("Result","No match result found."); | ||
} | ||
table.setData(machines); | ||
} catch (Throwable e1) { | ||
DeploySystemUI.showNotificationInfo("Error",e1.getMessage()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.