Skip to content

Commit

Permalink
Allow opening multiple tabs for the same cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Cher committed Jul 15, 2013
1 parent eafca36 commit 706d7fb
Showing 1 changed file with 30 additions and 36 deletions.
66 changes: 30 additions & 36 deletions src/main/java/hrider/ui/forms/Window.java
Expand Up @@ -443,55 +443,49 @@ public void run() {
private void loadView(Connection connection) {
DesignerView view = new DesignerView(this.topPanel, connection);

int index = this.tabbedPane.indexOfTab(connection.getServerName());
if (index == -1) {
index = this.tabbedPane.getTabCount();

JCloseButton closeButton = new JCloseButton(connection.getServerName(), this.tabbedPane);
this.viewMap.put(closeButton, view);

closeButton.addTabClosedListener(
new TabClosedListener() {
@Override
public void onTabClosed(Component component) {
DesignerView designerView = viewMap.get(component);

ClipboardData<DataTable> data = InMemoryClipboard.getData();
if (data != null) {
Connection helper = data.getData().getConnection();
if (helper != null) {
if (helper.equals(designerView.getConnection())) {
InMemoryClipboard.setData(null);
}
int index = this.tabbedPane.getTabCount();

JCloseButton closeButton = new JCloseButton(connection.getServerName(), this.tabbedPane);
this.viewMap.put(closeButton, view);

closeButton.addTabClosedListener(
new TabClosedListener() {
@Override
public void onTabClosed(Component component) {
DesignerView designerView = viewMap.get(component);

ClipboardData<DataTable> data = InMemoryClipboard.getData();
if (data != null) {
Connection helper = data.getData().getConnection();
if (helper != null) {
if (helper.equals(designerView.getConnection())) {
InMemoryClipboard.setData(null);
}
}
}

ViewConfig.instance().removeCluster(designerView.getConnection().getServerName());
ViewConfig.instance().removeCluster(designerView.getConnection().getServerName());

PropertiesConfig.fileRemove(designerView.getConnection().getServerName());
PropertiesConfig.fileRemove(designerView.getConnection().getServerName());

ConnectionManager.release(designerView.getConnection().getConnectionDetails());
viewMap.remove(component);
}
});
ConnectionManager.release(designerView.getConnection().getConnectionDetails());
viewMap.remove(component);
}
});

this.tabbedPane.addTab(connection.getServerName(), view.getView());
this.tabbedPane.setSelectedIndex(index);
this.tabbedPane.setTabComponentAt(index, closeButton);
this.tabbedPane.addTab(connection.getServerName(), view.getView());
this.tabbedPane.setSelectedIndex(index);
this.tabbedPane.setTabComponentAt(index, closeButton);

ViewConfig.instance().addCluster(connection.getServerName());
ViewConfig.instance().addCluster(connection.getServerName());

view.populate();
}
else {
this.tabbedPane.setSelectedIndex(index);
}
view.populate();
}

/**
* Shows a connection dialog.
*
* @return A reference to {@link hrider.config.ConnectionDetails} class that contains all required information to connect to the cluster.
* @return A reference to {@link ConnectionDetails} class that contains all required information to connect to the cluster.
*/
private ConnectionDetails showDialog() {
ConnectionDetailsDialog dialog = new ConnectionDetailsDialog();
Expand Down

0 comments on commit 706d7fb

Please sign in to comment.