Example usage for javax.swing.tree DefaultMutableTreeNode getUserObject

List of usage examples for javax.swing.tree DefaultMutableTreeNode getUserObject

Introduction

In this page you can find the example usage for javax.swing.tree DefaultMutableTreeNode getUserObject.

Prototype

public Object getUserObject() 

Source Link

Document

Returns this node's user object.

Usage

From source file:org.kuali.test.creator.TestCreator.java

/**
 *
 * @param actionNode/*from  w w  w .j  a va  2  s. c  o  m*/
 */
public void handleRemoveWebService(DefaultMutableTreeNode actionNode) {
    WebService ws = (WebService) actionNode.getUserObject();
    if (UIUtils.promptForDelete(this, "Delete Web Service", "Delete web service '" + ws.getName() + "'?")) {
        webServiceTree.removeNode(actionNode);
        if (Utils.removeRepositoryNode(getConfiguration(), actionNode)) {
            saveConfigurationButton.setEnabled(true);
            saveConfigurationMenuItem.setEnabled(true);
        }
    }
}

From source file:org.kuali.test.creator.TestCreator.java

/**
 *
 * @param actionNode//from  www  .  j ava 2s . com
 */
public void handleRemoveJmxConnection(DefaultMutableTreeNode actionNode) {
    JmxConnection jmx = (JmxConnection) actionNode.getUserObject();
    if (UIUtils.promptForDelete(this, "Delete JMX Connection",
            "Delete JMX connection '" + jmx.getName() + "'?")) {
        jmxTree.removeNode(actionNode);
        if (Utils.removeRepositoryNode(getConfiguration(), actionNode)) {
            saveConfigurationButton.setEnabled(true);
            saveConfigurationMenuItem.setEnabled(true);
        }
    }
}

From source file:org.kuali.test.creator.TestCreator.java

/**
 * //from  w  w w . j  a va 2s .  c  o m
 * @param platformNode 
 */
public void handleDeletePlatform(DefaultMutableTreeNode platformNode) {
    Platform platform = (Platform) platformNode.getUserObject();
    if (UIUtils.promptForDelete(this, "Delete Platform", "Delete platform '" + platform.getName() + "'")) {
        File fdir = new File(Utils.buildPlatformTestsDirectoryName(getConfiguration().getRepositoryLocation(),
                platform.getName()));
        if (fdir.exists() && fdir.isDirectory()) {
            try {
                FileUtils.deleteDirectory(fdir.getParentFile());

            } catch (IOException ex) {
                UIUtils.showError(this, "Delete Error",
                        "Error occured deleting platform '" + platform.getName() + "' - " + ex.toString());
            }
        }

        Platform[] platforms = getConfiguration().getPlatforms().getPlatformArray();

        for (int i = 0; i < platforms.length; ++i) {
            if (platforms[i].getName().equals(platform.getName())) {
                this.testRepositoryTree.removeNode(platformNode);
                getConfiguration().getPlatforms().removePlatform(i);
                saveConfigurationButton.setEnabled(true);
                saveConfigurationMenuItem.setEnabled(true);
                break;
            }
        }
    }
}

From source file:org.kuali.test.creator.TestCreator.java

/**
 *
 * @param actionNode//w ww  .  ja v a  2s .c om
 */
public void handleAddEditTestSuite(DefaultMutableTreeNode actionNode) {
    Platform platform = null;
    TestSuite testSuite = null;
    if (actionNode.getUserObject() instanceof Platform) {
        platform = (Platform) actionNode.getUserObject();
    } else {
        testSuite = (TestSuite) actionNode.getUserObject();
        DefaultMutableTreeNode pnode = (DefaultMutableTreeNode) actionNode.getParent();
        platform = (Platform) pnode.getUserObject();
    }

    TestSuiteDlg dlg = new TestSuiteDlg(this, platform, testSuite);

    if (dlg.isSaved()) {
        saveConfigurationButton.setEnabled(true);
        saveConfigurationMenuItem.setEnabled(true);
        if (!dlg.isEditmode()) {
            testRepositoryTree.addRepositoryNode(dlg.getNewRepositoryObject());
        }
    }
}

From source file:org.kuali.test.creator.TestCreator.java

/**
 *
 * @param actionNode/*from   w ww  . java 2s .c o  m*/
 */
public void handleShowTestInformation(DefaultMutableTreeNode actionNode) {
    SuiteTest suiteTest = (SuiteTest) actionNode.getUserObject();
    handleShowTestInformation(suiteTest.getTestHeader());
}

From source file:org.kuali.test.creator.TestCreator.java

/**
 *
 * @param actionNode/* w ww  .  j  a va  2 s .  com*/
 */
public void handleImportPlatformTests(DefaultMutableTreeNode actionNode) {
    ImportPlatformTestsDlg dlg = new ImportPlatformTestsDlg(this, (Platform) actionNode.getUserObject());

    if (dlg.isSaved()) {
        JOptionPane.showMessageDialog(this, "Successfully imported " + dlg.getImportedTestCount() + " tests");
        getPlatformTestsPanel().populateList((Platform) actionNode.getUserObject());
    }
}

From source file:org.kuali.test.creator.TestCreator.java

/**
 *
 * @param actionNode// ww w  .  j  a v  a  2 s .  c o m
 */
public void handleRemoveTest(DefaultMutableTreeNode actionNode) {
    SuiteTest suiteTest = (SuiteTest) actionNode.getUserObject();
    if (UIUtils.promptForDelete(this, "Remove Test",
            "Remove test '" + suiteTest.getTestHeader().getTestName() + "'?")) {
        testRepositoryTree.removeNode(actionNode);
        if (Utils.removeRepositoryNode(getConfiguration(), actionNode)) {
            saveConfigurationButton.setEnabled(true);
            saveConfigurationMenuItem.setEnabled(true);
        }
    }
}

From source file:org.kuali.test.creator.TestCreator.java

/**
 *
 * @param actionNode//from   ww w . j  av a2s .  co  m
 */
public void handleDeleteTestSuite(DefaultMutableTreeNode actionNode) {
    TestSuite testSuite = (TestSuite) actionNode.getUserObject();
    if (UIUtils.promptForDelete(this, "Delete Test Suite", "Delete test suite'" + testSuite.getName() + "'?")) {
        testRepositoryTree.removeNode(actionNode);
        if (Utils.removeRepositoryNode(getConfiguration(), actionNode)) {
            saveConfigurationButton.setEnabled(true);
            saveConfigurationMenuItem.setEnabled(true);
        }
    }
}

From source file:org.kuali.test.creator.TestCreator.java

/**
 *
 * @param actionNode// w  w w . j  a v  a  2s.c  o  m
 */
public void handleRemoveDatabaseConnection(DefaultMutableTreeNode actionNode) {
    DatabaseConnection dbconn = (DatabaseConnection) actionNode.getUserObject();
    if (UIUtils.promptForDelete(this, "Delete Database Connection",
            "Delete database connection '" + dbconn.getName() + "'?")) {
        databaseTree.removeNode(actionNode);
        if (Utils.removeRepositoryNode(getConfiguration(), actionNode)) {
            saveConfigurationButton.setEnabled(true);
            saveConfigurationMenuItem.setEnabled(true);
        }
    }
}

From source file:org.kuali.test.creator.TestCreator.java

/**
 *
 * @param actionNode/*w w  w. j a va 2  s  .c o  m*/
 */
public void handleTestDatabaseConnection(DefaultMutableTreeNode actionNode) {
    DatabaseConnection dbconn = (DatabaseConnection) actionNode.getUserObject();
    Connection conn = null;
    try {
        conn = Utils.getDatabaseConnection(Utils.getEncryptionPassword(getConfiguration()), dbconn);
        if (conn != null) {
            JOptionPane.showMessageDialog(this, "Successfully connected to database " + dbconn.getName());
        } else {
            throw new Exception("Unknown connection error");
        }
    }

    catch (Exception ex) {
        UIUtils.showError(this, "Database Connection Failed",
                "Database connection to " + dbconn.getName() + " failed - " + ex.toString());
    }
}