Skip to content

Commit

Permalink
[change] subscription are now created using a non-deprecated method f…
Browse files Browse the repository at this point in the history
…rom ifmapj to build identifier objects
  • Loading branch information
bahellma committed Nov 17, 2014
1 parent 356397f commit 9f1589c
Showing 1 changed file with 45 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
* | | | | | |_| \__ \ |_| | (_| | _ |\__ \| _ |
* |_| |_| \__,_|___/\__|\ \__,_|_| |_||___/|_| |_|
* \____/
*
*
* =====================================================
*
*
* Hochschule Hannover
* (University of Applied Sciences and Arts, Hannover)
* Faculty IV, Dept. of Computer Science
* Ricklinger Stadtweg 118, 30459 Hannover, Germany
*
*
* Email: [email protected]
* Website: http://trust.f4.hs-hannover.de/
*
*
* This file is part of irongui, version 0.4.4,
* implemented by the Trust@HsH research group at the Hochschule Hannover.
* %%
Expand All @@ -26,9 +26,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down Expand Up @@ -65,11 +65,10 @@
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;

import de.hshannover.f4.trust.ifmapj.IfmapJ;
import de.hshannover.f4.trust.ifmapj.exception.IfmapErrorResult;
import de.hshannover.f4.trust.ifmapj.exception.IfmapException;
import de.hshannover.f4.trust.ifmapj.identifier.Identifier;
import de.hshannover.f4.trust.ifmapj.identifier.IdentifierFactory;
import de.hshannover.f4.trust.ifmapj.identifier.Identifiers;
import de.hshannover.f4.trust.ifmapj.identifier.IdentityType;
import de.hshannover.f4.trust.ifmapj.identifier.IpAddress;
import de.hshannover.f4.trust.irongui.Client;
Expand Down Expand Up @@ -108,7 +107,6 @@ public final class ViewController implements IdentifierChangedReceiver {
private HashMap<Connection, TreePanel> mConnection2TreePanel;
private Connection mSelectedConnection;
private JPopupMenu mQuickPopup;
private IdentifierFactory mIdentifierFactory;

private JMenu menu1;
private JMenu menu2;
Expand All @@ -125,7 +123,6 @@ public ViewController(IfmapFacade ifacade) {
mMainFrame = new MainFrame(this);
mConDialog = new ConnectionDialog(null);
mSubDialog = new SubscribeDialog();
mIdentifierFactory = IfmapJ.createIdentifierFactory();
mConnection2GraphPanel = new HashMap<Connection, GraphPanel>();
mGraphPanel2Connection = new HashMap<GraphPanel, Connection>();
mConnection2TreePanel = new HashMap<Connection, TreePanel>();
Expand Down Expand Up @@ -363,7 +360,7 @@ private void subscribeToIdentifier(IdentifierData data, int depth,
graph.reset();
graph.clearTable();
mConnection2TreePanel.get(mSelectedConnection)
.removeAllNodes();
.removeAllNodes();
}
}
String uuid = mIfmapFacade.subscribe(mSelectedConnection,
Expand Down Expand Up @@ -397,15 +394,20 @@ public void subscribe() {
String ip_admin = ip.textFieldDomain.getText().trim();
if (!ip_value.equals("")) {
IpAddress ipadrr;
if (ip.ip4.isSelected()) {
ipadrr = mIdentifierFactory.createIp4(ip_value);

} else {
ipadrr = mIdentifierFactory.createIp6(ip_value);
}
if (!ip_admin.equals("")) {
ipadrr.setAdministrativeDomain(ip_admin);
if (ip.ip4.isSelected()) {
ipadrr = Identifiers.createIp4(ip_value, ip_admin);
} else {
ipadrr = Identifiers.createIp6(ip_value, ip_admin);
}
} else {
if (ip.ip4.isSelected()) {
ipadrr = Identifiers.createIp4(ip_value);
} else {
ipadrr = Identifiers.createIp6(ip_value);
}
}

ident = ipadrr;
}
} else if (menu2.isSelected()) {
Expand All @@ -415,7 +417,7 @@ public void subscribe() {
String mac_val = mac.textFieldValue.getText().trim();
String mac_admin = mac.textFieldDomain.getText().trim();
if (!mac_val.equals("")) {
ident = mIdentifierFactory.createMac(mac_val, mac_admin);
ident = Identifiers.createMac(mac_val, mac_admin);
}
} else if (menu3.isSelected()) {
pan = (QuickSubscribePanel) menu3.getMenuComponent(0);
Expand All @@ -424,7 +426,7 @@ public void subscribe() {
String name = ar.textFieldName.getText().trim();
String admin = ar.textFieldAdmin.getText().trim();
if (!name.equals("")) {
ident = mIdentifierFactory.createAr(name, admin);
ident = Identifiers.createAr(name);
}
} else if (menu4.isSelected()) {
pan = (QuickSubscribePanel) menu4.getMenuComponent(0);
Expand All @@ -435,15 +437,14 @@ public void subscribe() {
String admin = id.textFieldDomain.getText().trim();

if (!name.equals("")) {
String type = id.type.getSelection().getActionCommand();
if (type.equals(IdentityType.other.toString())) {
String typeAsString = id.type.getSelection().getActionCommand();
if (typeAsString.equals(IdentityType.other.toString())) {
if (!other.equals("")) {
ident = mIdentifierFactory.createIdentity(name,
admin, other);
ident = Identifiers.createOtherIdentity(name, admin, other);
}
} else {
ident = mIdentifierFactory.createIdentity(type, name,
admin);
IdentityType type = Identifiers.getIdentityType(typeAsString);
ident = Identifiers.createIdentity(type, name, admin);
}
}

Expand All @@ -453,7 +454,7 @@ public void subscribe() {
.getQuickComponent();
String dev_val = dev.textFieldName.getText().trim();
if (!dev_val.equals("")) {
ident = mIdentifierFactory.createDev(dev_val);
ident = Identifiers.createDev(dev_val);
}
}
}
Expand All @@ -480,8 +481,8 @@ public void showConnectionDialog() {
mConDialog.addConnections(cons);
mConDialog.setLocationRelativeTo(null);
mConDialog
.setSelectedConnection((Connection) mMainFrame.navigationPanel.panelList
.getSelectedValue());
.setSelectedConnection((Connection) mMainFrame.navigationPanel.panelList
.getSelectedValue());
mConDialog.setVisible(true);
}

Expand All @@ -492,7 +493,7 @@ public void tabChanged() {
if (con != null) {
if (mMainFrame.navigationPanel.buttonTree.isSelected()) {
mMainFrame.navigationPanel
.removeView(mMainFrame.navigationPanel.panelTree);
.removeView(mMainFrame.navigationPanel.panelTree);
TreePanel tree = mConnection2TreePanel.get(con);
mMainFrame.navigationPanel.addView(tree);
mMainFrame.navigationPanel.panelTree = mConnection2TreePanel
Expand Down Expand Up @@ -551,7 +552,7 @@ public void toggleConnection() {
final String[] keys = subs.keySet().toArray(
new String[0]);
SubscriptionRepository.getInstance()
.removeSubscriptions(mSelectedConnection, keys);
.removeSubscriptions(mSelectedConnection, keys);
}
if (mSelectedConnection.getConnectionParameters()
.isDump()) {
Expand All @@ -564,16 +565,16 @@ public void toggleConnection() {
graph.enableAnimation(true);
mMainFrame.metadataPanel.label.setText("");
mConnection2TreePanel.get(mSelectedConnection)
.removeAllNodes();
.removeAllNodes();
mMainFrame.navigationPanel.revalidate();
mMainFrame.status.setText("Session "
+ mSelectedConnection.getEndpoint() + "terminated");
mMainFrame.navigationPanel.panelList.updateUI();
graph.updateUI();
graph.repaint();
graph.repaint();
}
mMainFrame.navigationPanel.buttonPlay
.setSelected(mSelectedConnection.isConnected());
.setSelected(mSelectedConnection.isConnected());
mMainFrame.toolbarPanel.buttonAnimation.setSelected(!graph.isAnimationEnabled());
}

Expand All @@ -593,8 +594,8 @@ public void toggleConnection() {
}

public void enableDump(boolean enable) throws FileNotFoundException,
PropertiesNotFoundException, IOException, IfmapErrorResult,
IfmapException, InterruptedException {
PropertiesNotFoundException, IOException, IfmapErrorResult,
IfmapException, InterruptedException {
if (mSelectedConnection != null) {
if (enable) {
mIfmapFacade.startSession(mSelectedConnection);
Expand Down Expand Up @@ -633,7 +634,7 @@ public void selectConnectionWithoutCreatingTab(Connection con) {
mMainFrame.navigationPanel.buttonPlay.setSelected(con.isConnected());
mSelectedConnection = con;
}

public void selectConnection(Connection con) {
GraphPanel graph = mConnection2GraphPanel.get(con);
if (graph == null) {
Expand All @@ -659,11 +660,12 @@ public void selectConnection(Connection con) {
boolean b = false;
for (int i = 0; i < mMainFrame.tabbedPane.getTabCount(); i++) {
Component c = mMainFrame.tabbedPane.getComponentAt(i);
if (c == graph)
if (c == graph) {
b = true;
}
}

if (!b) {
if (!b) {
mMainFrame.tabbedPane.addTab(con.getName(), new ImageIcon(
getClass().getClassLoader().getResource("tabConnect.png")),
graph, con.getName());
Expand All @@ -673,7 +675,7 @@ public void selectConnection(Connection con) {
}

mMainFrame.tabbedPane.setSelectedComponent(graph);

mMainFrame.navigationPanel.buttonPlay.setSelected(con.isConnected());
mMainFrame.toolbarPanel.buttonAnimation.setSelected(!graph.isAnimationEnabled());
graph.revalidate();
Expand All @@ -691,7 +693,7 @@ public void treeButtonClicked() {
}
}
mMainFrame.navigationPanel.updateUI();

}

public void conButtonClicked() {
Expand Down Expand Up @@ -725,7 +727,7 @@ public void toggleAnimation() {
p.toggleAnimation();
}
}

@Override
public void processNewPollResult(Connection con,
ArrayList<IfmapDataType> newData,
Expand All @@ -738,7 +740,7 @@ public void processNewPollResult(Connection con,
TreePanel tree = mConnection2TreePanel.get(con);
tree.processNewPollResult(newData, updateData, deleteData);
mPubDialog
.processNewPollResult(newData, updateData, deleteData);
.processNewPollResult(newData, updateData, deleteData);
graph.centerGraph();
}
}
Expand Down

0 comments on commit 9f1589c

Please sign in to comment.