Skip to content

Commit

Permalink
added the ability to dock a tab to the bottom of the Armitage window.…
Browse files Browse the repository at this point in the history
… Use Ctrl+B to do it.
  • Loading branch information
rsmudge committed Sep 9, 2014
1 parent 3732569 commit 55f34e7
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 1 deletion.
2 changes: 2 additions & 0 deletions scripts/menus.sl
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ sub init_menus {
}];
[$frame bindKey: "Ctrl+N", { thread(&createConsoleTab); }];
[$frame bindKey: "Ctrl+W", { [$frame openActiveTab]; }];
[$frame bindKey: "Ctrl+B", { [$frame dockActiveTab]; }];
[$frame bindKey: "Ctrl+E", { [$frame noDock]; }];
[$frame bindKey: "Ctrl+D", { [$frame closeActiveTab]; }];
[$frame bindKey: "Ctrl+O", { thread(&createPreferencesTab); }];
[$frame bindKey: "Ctrl+T", { [$frame snapActiveTab]; }];
Expand Down
69 changes: 68 additions & 1 deletion src/armitage/ArmitageApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ public class ArmitageApplication extends JComponent {
protected KeyBindings keys = new KeyBindings();
protected MenuBuilder builder = null;
protected String title = "";

protected MultiFrame window = null;
protected JSplitPane split2 = null;
protected ApplicationTab docked = null;

public KeyBindings getBindings() {
return keys;
Expand Down Expand Up @@ -181,6 +184,28 @@ public void openActiveTab() {
}
}


public void noDock() {
if (docked != null) {
if (docked.removeListener != null) {
docked.removeListener.actionPerformed(new ActionEvent(docked.component, 0, "close"));
}

split2.setBottomComponent(null);
split2.setDividerSize(0);
split2.setResizeWeight(1.0);
validate();
docked = null;
}
}

public void dockActiveTab() {
JComponent tab = (JComponent)tabs.getSelectedComponent();
if (tab != null) {
dockAppTab(tab);
}
}

public void snapActiveTab() {
JComponent tab = (JComponent)tabs.getSelectedComponent();
Iterator i = apptabs.iterator();
Expand Down Expand Up @@ -280,6 +305,36 @@ public void windowActivated(WindowEvent ev) {
}
}

public void dockAppTab(Component tab) {
Iterator i = apptabs.iterator();
while (i.hasNext()) {
final ApplicationTab t = (ApplicationTab)i.next();
if (t.component == tab) {
tabs.remove(t.component);
i.remove();

Dimension size = new Dimension(100, 150);

/* fire old docked items listener (necessary for some cleanup) */
if (docked != null) {
size = docked.component.getSize();
if (docked.removeListener != null)
docked.removeListener.actionPerformed(new ActionEvent(docked.component, 0, "close"));
}

/* pop goes the tab! */
split2.setBottomComponent(t.component);
split2.setDividerSize(10);
split2.setResizeWeight(1.0);
t.component.setPreferredSize(size);
t.component.setSize(size);
validate();

docked = t;
}
}
}

public void snapAppTab(String title, Component tab) {
/* capture the current tab in an image */
BufferedImage image = new BufferedImage(tab.getWidth(), tab.getHeight(), BufferedImage.TYPE_4BYTE_ABGR);
Expand Down Expand Up @@ -363,6 +418,13 @@ public void actionPerformed(ActionEvent ev) {
}
});

JMenuItem dd = new JMenuItem("Send to bottom", 'b');
dd.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
dockAppTab(component);
}
});

JMenuItem d = new JMenuItem("Rename Tab", 'R');
d.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
Expand All @@ -374,6 +436,7 @@ public void actionPerformed(ActionEvent ev) {

menu.add(a);
menu.add(c);
menu.add(dd);
menu.add(d);
menu.addSeparator();
menu.add(b);
Expand Down Expand Up @@ -449,7 +512,11 @@ public ArmitageApplication(MultiFrame f, String details, msf.RpcConnection conn)
/* add our menubar */
add(menus, BorderLayout.NORTH);

split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, panel, tabs);
split2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, tabs, null);
split2.setDividerSize(0);
split2.setOneTouchExpandable(true);

split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, panel, split2);
split.setOneTouchExpandable(true);

/* add our tabbed pane */
Expand Down
3 changes: 3 additions & 0 deletions whatsnew.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Armitage Changelog
In Progress
---------
- Added helper for SCRIPT option.
- Right-click a tab's X button and use "Send to bottom" or Ctrl+B to
dock a tab to the bottom of the Armitage window. Use Ctrl+E to get
get rid of the docked tab..

18 Aug 14 (tested against msf git revision: 55ef5dd484)
---------
Expand Down

0 comments on commit 55f34e7

Please sign in to comment.