Example usage for java.lang Thread isAlive

List of usage examples for java.lang Thread isAlive

Introduction

In this page you can find the example usage for java.lang Thread isAlive.

Prototype

public final native boolean isAlive();

Source Link

Document

Tests if this thread is alive.

Usage

From source file:com.gft.unity.android.AndroidIO.java

@Override
public String InvokeServiceForBinary(IORequest request, IOService service, String storePath) {

    IOServiceEndpoint endpoint = service.getEndpoint();

    if (service != null) {
        // JUST FOR LOCAL TESTING, DO NOT UNCOMMENT FOR PLATFORM RELEASE
        // LOG.LogDebug(Module.PLATFORM, "Request content (for binary): " + request.getContent());

        if (endpoint == null) {
            LOG.LogDebug(Module.PLATFORM, "No endpoint configured for this service name: " + service.getName());
            return null;
        }/*from ww w  .ja va2  s.  c  o m*/

        if (!ServiceType.OCTET_BINARY.equals(service.getType())) {
            LOG.LogDebug(Module.PLATFORM, "This method only admits OCTET_BINARY service types");
            return null;
        }

        String requestMethod = service.getRequestMethod().toString();
        if (request.getMethod() != null && request.getMethod().length() > 0)
            requestMethod = request.getMethod().toUpperCase();

        String requestUriString = formatRequestUriString(request, endpoint, requestMethod);
        Thread timeoutThread = null;

        try {

            // Security - VALIDATIONS
            if (!this.applySecurityValidations(requestUriString)) {
                return null;
            }

            // Adding HTTP Client Parameters
            this.addingHttpClientParms(request, endpoint);

            // Building Web Request to send
            HttpEntityEnclosingRequestBase httpRequest = this.buildWebRequest(request, service,
                    requestUriString, requestMethod);

            LOG.LogDebug(Module.PLATFORM, "Downloading service content");

            // Throw a new Thread to check absolute timeout
            timeoutThread = new Thread(new CheckTimeoutThread(httpRequest));
            timeoutThread.start();

            long start = System.currentTimeMillis();
            HttpResponse httpResponse = httpClient.execute(httpRequest);
            LOG.LogDebug(Module.PLATFORM,
                    "Content downloaded in " + (System.currentTimeMillis() - start) + "ms");

            // Read response and store to local filestystem
            return this.readWebResponseAndStore(httpResponse, service, storePath);

        } catch (Exception ex) {
            LOG.Log(Module.PLATFORM, "Unnandled Exception requesting service.", ex);
        } finally {
            // abort any previous timeout checking thread
            if (timeoutThread != null && timeoutThread.isAlive()) {
                timeoutThread.interrupt();
            }
        }
    }

    LOG.LogDebug(Module.PLATFORM, "invoke service (for binary) finished");
    return null;
}

From source file:com.meltmedia.cadmium.servlets.ClassLoaderLeakPreventor.java

/**
 * Partially inspired by org.apache.catalina.loader.WebappClassLoader.clearReferencesThreads()
 *///  w  ww  . ja  v  a 2s  .co m
@SuppressWarnings("deprecation")
protected void stopThreads() {
    final Class<?> workerClass = findClass("java.util.concurrent.ThreadPoolExecutor$Worker");
    final Field oracleTarget = findField(Thread.class, "target"); // Sun/Oracle JRE
    final Field ibmRunnable = findField(Thread.class, "runnable"); // IBM JRE

    for (Thread thread : getAllThreads()) {
        @SuppressWarnings("RedundantCast")
        final Runnable runnable = (oracleTarget != null) ? (Runnable) getFieldValue(oracleTarget, thread) : // Sun/Oracle JRE  
                (Runnable) getFieldValue(ibmRunnable, thread); // IBM JRE

        if (thread != Thread.currentThread() && // Ignore current thread
                (isThreadInWebApplication(thread) || isLoadedInWebApplication(runnable))) {

            if (thread.getClass().getName().startsWith(JURT_ASYNCHRONOUS_FINALIZER)) {
                // Note, the thread group of this thread may be "system" if it is triggered by the Garbage Collector
                // however if triggered by us in forceStartOpenOfficeJurtCleanup() it may depend on the application server
                if (stopThreads) {
                    info("Found JURT thread " + thread.getName() + "; starting "
                            + JURTKiller.class.getSimpleName());
                    new JURTKiller(thread).start();
                } else
                    warn("JURT thread " + thread.getName() + " is still running in web app");
            } else if (thread.getThreadGroup() != null && ("system".equals(thread.getThreadGroup().getName()) || // System thread
                    "RMI Runtime".equals(thread.getThreadGroup().getName()))) { // RMI thread (honestly, just copied from Tomcat)

                if ("Keep-Alive-Timer".equals(thread.getName())) {
                    thread.setContextClassLoader(getWebApplicationClassLoader().getParent());
                    debug("Changed contextClassLoader of HTTP keep alive thread");
                }
            } else if (thread.isAlive()) { // Non-system, running in web app

                if ("java.util.TimerThread".equals(thread.getClass().getName())) {
                    if (stopTimerThreads) {
                        warn("Stopping Timer thread running in classloader.");
                        stopTimerThread(thread);
                    } else {
                        info("Timer thread is running in classloader, but will not be stopped");
                    }
                } else {
                    // If threads is running an java.util.concurrent.ThreadPoolExecutor.Worker try shutting down the executor
                    if (workerClass != null && workerClass.isInstance(runnable)) {
                        if (stopThreads) {
                            warn("Shutting down " + ThreadPoolExecutor.class.getName()
                                    + " running within the classloader.");
                            try {
                                // java.util.concurrent.ThreadPoolExecutor, introduced in Java 1.5
                                final Field workerExecutor = findField(workerClass, "this$0");
                                final ThreadPoolExecutor executor = getFieldValue(workerExecutor, runnable);
                                executor.shutdownNow();
                            } catch (Exception ex) {
                                error(ex);
                            }
                        } else
                            info(ThreadPoolExecutor.class.getName()
                                    + " running within the classloader will not be shut down.");
                    }

                    final String displayString = "'" + thread + "' of type " + thread.getClass().getName();

                    if (stopThreads) {
                        final String waitString = (threadWaitMs > 0) ? "after " + threadWaitMs + " ms " : "";
                        warn("Stopping Thread " + displayString + " running in web app " + waitString);

                        if (threadWaitMs > 0) {
                            try {
                                thread.join(threadWaitMs); // Wait for thread to run
                            } catch (InterruptedException e) {
                                // Do nothing
                            }
                        }

                        // Normally threads should not be stopped (method is deprecated), since it may cause an inconsistent state.
                        // In this case however, the alternative is a classloader leak, which may or may not be considered worse.
                        if (thread.isAlive())
                            thread.stop();
                    } else {
                        warn("Thread " + displayString + " is still running in web app");
                    }

                }
            }
        }
    }
}

From source file:se.jiderhamn.classloader.leak.prevention.ClassLoaderLeakPreventor.java

/**
 * Partially inspired by org.apache.catalina.loader.WebappClassLoader.clearReferencesThreads()
 *//*from w  ww . j a  va 2  s  . co  m*/
@SuppressWarnings("deprecation")
protected void stopThreads() {
    final Class<?> workerClass = findClass("java.util.concurrent.ThreadPoolExecutor$Worker");
    final Field oracleTarget = findField(Thread.class, "target"); // Sun/Oracle JRE
    final Field ibmRunnable = findField(Thread.class, "runnable"); // IBM JRE

    for (Thread thread : getAllThreads()) {
        final Runnable runnable = (oracleTarget != null) ? (Runnable) getFieldValue(oracleTarget, thread) : // Sun/Oracle JRE  
                (Runnable) getFieldValue(ibmRunnable, thread); // IBM JRE

        if (thread != Thread.currentThread() && // Ignore current thread
                (isThreadInWebApplication(thread) || isLoadedInWebApplication(runnable))) {

            if (thread.getClass().getName().startsWith(JURT_ASYNCHRONOUS_FINALIZER)) {
                // Note, the thread group of this thread may be "system" if it is triggered by the Garbage Collector
                // however if triggered by us in forceStartOpenOfficeJurtCleanup() it may depend on the application server
                if (stopThreads) {
                    info("Found JURT thread " + thread.getName() + "; starting "
                            + JURTKiller.class.getSimpleName());
                    new JURTKiller(thread).start();
                } else
                    warn("JURT thread " + thread.getName() + " is still running in web app");
            } else if (thread.getThreadGroup() != null && ("system".equals(thread.getThreadGroup().getName()) || // System thread
                    "RMI Runtime".equals(thread.getThreadGroup().getName()))) { // RMI thread (honestly, just copied from Tomcat)

                if ("Keep-Alive-Timer".equals(thread.getName())) {
                    thread.setContextClassLoader(getWebApplicationClassLoader().getParent());
                    debug("Changed contextClassLoader of HTTP keep alive thread");
                }
            } else if (thread.isAlive()) { // Non-system, running in web app

                if ("java.util.TimerThread".equals(thread.getClass().getName())) {
                    if (stopTimerThreads) {
                        warn("Stopping Timer thread running in classloader.");
                        stopTimerThread(thread);
                    } else {
                        info("Timer thread is running in classloader, but will not be stopped");
                    }
                } else {
                    // If threads is running an java.util.concurrent.ThreadPoolExecutor.Worker try shutting down the executor
                    if (workerClass != null && workerClass.isInstance(runnable)) {
                        if (stopThreads) {
                            warn("Shutting down " + ThreadPoolExecutor.class.getName()
                                    + " running within the classloader.");
                            try {
                                // java.util.concurrent.ThreadPoolExecutor, introduced in Java 1.5
                                final Field workerExecutor = findField(workerClass, "this$0");
                                final ThreadPoolExecutor executor = getFieldValue(workerExecutor, runnable);
                                executor.shutdownNow();
                            } catch (Exception ex) {
                                error(ex);
                            }
                        } else
                            info(ThreadPoolExecutor.class.getName()
                                    + " running within the classloader will not be shut down.");
                    }

                    final String displayString = "'" + thread + "' of type " + thread.getClass().getName();

                    if (stopThreads) {
                        final String waitString = (threadWaitMs > 0) ? "after " + threadWaitMs + " ms " : "";
                        warn("Stopping Thread " + displayString + " running in web app " + waitString);

                        if (threadWaitMs > 0) {
                            try {
                                thread.join(threadWaitMs); // Wait for thread to run
                            } catch (InterruptedException e) {
                                // Do nothing
                            }
                        }

                        // Normally threads should not be stopped (method is deprecated), since it may cause an inconsistent state.
                        // In this case however, the alternative is a classloader leak, which may or may not be considered worse.
                        if (thread.isAlive())
                            thread.stop();
                    } else {
                        warn("Thread " + displayString + " is still running in web app");
                    }

                }
            }
        }
    }
}

From source file:azkaban.execapp.FlowRunnerTest2.java

/**
 * Tests the case when a flow is paused and a failure causes a kill. The
 * flow should die immediately regardless of the 'paused' status.
 * @throws Exception/*from  ww  w .j  a va  2 s .  com*/
 */
@Ignore
@Test
public void testPauseFailKill() throws Exception {
    EventCollectorListener eventCollector = new EventCollectorListener();
    FlowRunner runner = createFlowRunner(eventCollector, "jobf", FailureAction.CANCEL_ALL);

    Map<String, Status> expectedStateMap = new HashMap<String, Status>();
    Map<String, ExecutableNode> nodeMap = new HashMap<String, ExecutableNode>();

    // 1. START FLOW
    ExecutableFlow flow = runner.getExecutableFlow();
    createExpectedStateMap(flow, expectedStateMap, nodeMap);
    Thread thread = runFlowRunnerInThread(runner);
    pause(250);
    // After it starts up, only joba should be running
    expectedStateMap.put("joba", Status.RUNNING);
    expectedStateMap.put("joba1", Status.RUNNING);
    compareStates(expectedStateMap, nodeMap);

    // 2. JOB A COMPLETES SUCCESSFULLY
    InteractiveTestJob.getTestJob("joba").succeedJob();
    pause(500);
    expectedStateMap.put("joba", Status.SUCCEEDED);
    expectedStateMap.put("joba1", Status.RUNNING);
    expectedStateMap.put("jobb", Status.RUNNING);
    expectedStateMap.put("jobc", Status.RUNNING);
    expectedStateMap.put("jobd", Status.RUNNING);
    expectedStateMap.put("jobd:innerJobA", Status.RUNNING);
    expectedStateMap.put("jobb:innerJobA", Status.RUNNING);
    compareStates(expectedStateMap, nodeMap);

    runner.pause("me");
    pause(250);
    Assert.assertEquals(flow.getStatus(), Status.PAUSED);
    InteractiveTestJob.getTestJob("jobd:innerJobA").failJob();
    pause(250);
    expectedStateMap.put("jobd:innerJobA", Status.FAILED);
    expectedStateMap.put("jobd:innerFlow2", Status.CANCELLED);
    expectedStateMap.put("jobd", Status.FAILED);
    expectedStateMap.put("jobb:innerJobA", Status.KILLED);
    expectedStateMap.put("jobb:innerJobB", Status.CANCELLED);
    expectedStateMap.put("jobb:innerJobC", Status.CANCELLED);
    expectedStateMap.put("jobb:innerFlow", Status.CANCELLED);
    expectedStateMap.put("jobb", Status.KILLED);
    expectedStateMap.put("jobc", Status.KILLED);
    expectedStateMap.put("jobe", Status.CANCELLED);
    expectedStateMap.put("jobf", Status.CANCELLED);
    expectedStateMap.put("joba1", Status.KILLED);
    compareStates(expectedStateMap, nodeMap);

    Assert.assertEquals(Status.FAILED, flow.getStatus());
    Assert.assertFalse(thread.isAlive());
}

From source file:com.gft.unity.android.AndroidIO.java

@Override
public IOResponse InvokeService(IORequest request, IOService service) {

    IOServiceEndpoint endpoint = service.getEndpoint();
    IOResponse response = new IOResponse();

    if (service != null) {
        // JUST FOR LOCAL TESTING, DO NOT UNCOMMENT FOR PLATFORM RELEASE
        // LOG.LogDebug(Module.PLATFORM, "Request content: " + request.getContent());

        if (endpoint == null) {
            LOG.LogDebug(Module.PLATFORM, "No endpoint configured for this service name: " + service.getName());
            return response;
        }/*  w  ww. j  av a  2  s .  c  om*/

        String requestMethod = service.getRequestMethod().toString();
        if (request.getMethod() != null && request.getMethod().length() > 0)
            requestMethod = request.getMethod().toUpperCase();

        String requestUriString = formatRequestUriString(request, endpoint, requestMethod);
        Thread timeoutThread = null;

        try {

            // Security - VALIDATIONS
            if (!this.applySecurityValidations(requestUriString)) {
                return null;
            }

            // Adding HTTP Client Parameters
            this.addingHttpClientParms(request, endpoint);

            // Building Web Request to send
            HttpEntityEnclosingRequestBase httpRequest = this.buildWebRequest(request, service,
                    requestUriString, requestMethod);

            LOG.LogDebug(Module.PLATFORM, "Downloading service content");

            // Throw a new Thread to check absolute timeout
            timeoutThread = new Thread(new CheckTimeoutThread(httpRequest));
            timeoutThread.start();

            long start = System.currentTimeMillis();
            HttpResponse httpResponse = httpClient.execute(httpRequest);
            LOG.LogDebug(Module.PLATFORM,
                    "Content downloaded in " + (System.currentTimeMillis() - start) + "ms");

            // Read response
            response = this.readWebResponse(httpResponse, service);

        } catch (Exception ex) {
            LOG.Log(Module.PLATFORM, "Unnandled Exception requesting service.", ex);
            response.setContentType(contentTypes.get(ServiceType.REST_JSON).toString());
            response.setContent("Unhandled Exception Requesting Service. Message: " + ex.getMessage());
        } finally {
            // abort any previous timeout checking thread
            if (timeoutThread != null && timeoutThread.isAlive()) {
                timeoutThread.interrupt();
            }
        }
    }

    LOG.LogDebug(Module.PLATFORM, "invoke service finished");
    return response;
}

From source file:org.apache.hadoop.hdfs.server.datanode.FSDataset.java

/**
 * Return a list of active writer threads for the given block.
 * @return null if there are no such threads or the file is
 * not being created//from  ww w.  ja  v  a2 s  .  c o m
 */
private ArrayList<Thread> getActiveThreads(int namespaceId, Block block) {
    lock.writeLock().lock();
    try {
        //check ongoing create threads
        final ActiveFile activefile = volumeMap.getOngoingCreates(namespaceId, block);
        if (activefile != null && !activefile.threads.isEmpty()) {
            //remove dead threads
            for (Iterator<Thread> i = activefile.threads.iterator(); i.hasNext();) {
                final Thread t = i.next();
                if (!t.isAlive()) {
                    i.remove();
                }
            }

            //return living threads
            if (!activefile.threads.isEmpty()) {
                return new ArrayList<Thread>(activefile.threads);
            }
        }
    } finally {
        lock.writeLock().unlock();
    }
    return null;
}

From source file:azkaban.execapp.FlowRunnerTest2.java

/**
 * Tests the failure condition when a failure invokes a cancel (or killed)
 * on the flow./*from   w w  w.  ja va  2  s.  c  o m*/
 *
 * Any jobs that are running will be assigned a KILLED state, and any nodes
 * which were skipped due to prior errors will be given a CANCELLED state.
 *
 * @throws Exception
 */
@Ignore
@Test
public void testCancelOnFailure() throws Exception {
    // Test propagation of KILLED status to embedded flows different branch
    EventCollectorListener eventCollector = new EventCollectorListener();
    FlowRunner runner = createFlowRunner(eventCollector, "jobf", FailureAction.CANCEL_ALL);
    ExecutableFlow flow = runner.getExecutableFlow();
    Map<String, Status> expectedStateMap = new HashMap<String, Status>();
    Map<String, ExecutableNode> nodeMap = new HashMap<String, ExecutableNode>();

    // 1. START FLOW
    createExpectedStateMap(flow, expectedStateMap, nodeMap);
    Thread thread = runFlowRunnerInThread(runner);
    pause(250);

    // After it starts up, only joba should be running
    expectedStateMap.put("joba", Status.RUNNING);
    expectedStateMap.put("joba1", Status.RUNNING);
    compareStates(expectedStateMap, nodeMap);

    // 2. JOB in subflow FAILS
    InteractiveTestJob.getTestJob("joba").succeedJob();
    pause(250);
    expectedStateMap.put("joba", Status.SUCCEEDED);
    expectedStateMap.put("jobb", Status.RUNNING);
    expectedStateMap.put("jobc", Status.RUNNING);
    expectedStateMap.put("jobd", Status.RUNNING);
    expectedStateMap.put("jobb:innerJobA", Status.RUNNING);
    expectedStateMap.put("jobd:innerJobA", Status.RUNNING);
    compareStates(expectedStateMap, nodeMap);

    InteractiveTestJob.getTestJob("joba1").succeedJob();
    InteractiveTestJob.getTestJob("jobb:innerJobA").succeedJob();
    pause(250);
    expectedStateMap.put("jobb:innerJobA", Status.SUCCEEDED);
    expectedStateMap.put("joba1", Status.SUCCEEDED);
    expectedStateMap.put("jobb:innerJobB", Status.RUNNING);
    expectedStateMap.put("jobb:innerJobC", Status.RUNNING);
    compareStates(expectedStateMap, nodeMap);

    InteractiveTestJob.getTestJob("jobb:innerJobB").failJob();
    pause(250);
    expectedStateMap.put("jobb", Status.FAILED);
    expectedStateMap.put("jobb:innerJobB", Status.FAILED);
    expectedStateMap.put("jobb:innerJobC", Status.KILLED);
    expectedStateMap.put("jobb:innerFlow", Status.CANCELLED);
    expectedStateMap.put("jobc", Status.KILLED);
    expectedStateMap.put("jobd", Status.KILLED);
    expectedStateMap.put("jobd:innerJobA", Status.KILLED);
    expectedStateMap.put("jobd:innerFlow2", Status.CANCELLED);
    expectedStateMap.put("jobe", Status.CANCELLED);
    expectedStateMap.put("jobf", Status.CANCELLED);
    compareStates(expectedStateMap, nodeMap);

    Assert.assertFalse(thread.isAlive());
    Assert.assertEquals(Status.FAILED, flow.getStatus());

}

From source file:azkaban.execapp.FlowRunnerTest2.java

/**
 * Tests the manual Killing of a flow. In this case, the flow is just fine
 * before the cancel/*w  w  w. ja  va 2  s  . c o m*/
 * is called.
 *
 * @throws Exception
 */
@Ignore
@Test
public void testCancel() throws Exception {
    // Test propagation of KILLED status to embedded flows different branch
    EventCollectorListener eventCollector = new EventCollectorListener();
    FlowRunner runner = createFlowRunner(eventCollector, "jobf", FailureAction.CANCEL_ALL);
    ExecutableFlow flow = runner.getExecutableFlow();
    Map<String, Status> expectedStateMap = new HashMap<String, Status>();
    Map<String, ExecutableNode> nodeMap = new HashMap<String, ExecutableNode>();

    // 1. START FLOW
    createExpectedStateMap(flow, expectedStateMap, nodeMap);
    Thread thread = runFlowRunnerInThread(runner);
    pause(1000);

    // After it starts up, only joba should be running
    expectedStateMap.put("joba", Status.RUNNING);
    expectedStateMap.put("joba1", Status.RUNNING);
    compareStates(expectedStateMap, nodeMap);

    // 2. JOB in subflow FAILS
    InteractiveTestJob.getTestJob("joba").succeedJob();
    pause(250);
    expectedStateMap.put("joba", Status.SUCCEEDED);
    expectedStateMap.put("jobb", Status.RUNNING);
    expectedStateMap.put("jobc", Status.RUNNING);
    expectedStateMap.put("jobd", Status.RUNNING);
    expectedStateMap.put("jobb:innerJobA", Status.RUNNING);
    expectedStateMap.put("jobd:innerJobA", Status.RUNNING);
    compareStates(expectedStateMap, nodeMap);

    InteractiveTestJob.getTestJob("joba1").succeedJob();
    InteractiveTestJob.getTestJob("jobb:innerJobA").succeedJob();
    pause(250);
    expectedStateMap.put("jobb:innerJobA", Status.SUCCEEDED);
    expectedStateMap.put("joba1", Status.SUCCEEDED);
    expectedStateMap.put("jobb:innerJobB", Status.RUNNING);
    expectedStateMap.put("jobb:innerJobC", Status.RUNNING);
    compareStates(expectedStateMap, nodeMap);

    runner.kill("me");
    pause(250);

    expectedStateMap.put("jobb", Status.KILLED);
    expectedStateMap.put("jobb:innerJobB", Status.KILLED);
    expectedStateMap.put("jobb:innerJobC", Status.KILLED);
    expectedStateMap.put("jobb:innerFlow", Status.CANCELLED);
    expectedStateMap.put("jobc", Status.KILLED);
    expectedStateMap.put("jobd", Status.KILLED);
    expectedStateMap.put("jobd:innerJobA", Status.KILLED);
    expectedStateMap.put("jobd:innerFlow2", Status.CANCELLED);
    expectedStateMap.put("jobe", Status.CANCELLED);
    expectedStateMap.put("jobf", Status.CANCELLED);

    Assert.assertEquals(Status.KILLED, flow.getStatus());
    compareStates(expectedStateMap, nodeMap);
    Assert.assertFalse(thread.isAlive());
}

From source file:com.project.traceability.GUI.ProjectCreateWindow.java

/**
 * Create contents of the window.// w  ww  .  j  av  a 2 s. c om
 */
protected void createContents() {
    shell = new Shell();
    shell.setSize(622, 833);
    shell.setText("SWT Application");

    Dimension.toCenter(shell);// set the shell into center point
    Group group = new Group(shell, SWT.NONE);
    group.setText("Project");
    group.setBounds(20, 42, 556, 137);

    Label label = new Label(group, SWT.NONE);
    label.setText("New Workspace Path");
    label.setBounds(0, 5, 175, 18);

    lalProjectWrkspace = new Label(shell, SWT.NONE);
    lalProjectWrkspace.setText(StaticData.workspace);
    lalProjectWrkspace.setBounds(221, 10, 347, 17);

    textWrkspace = new Text(group, SWT.BORDER);
    textWrkspace.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {

            if (e.keyCode == 10) {

                // The Project work space is entered and pressed enter
                // button
                String path = textWrkspace.getText().toString();
                File file = new File(path);

                if (!(file.isDirectory() || file.exists())) {
                    txtProjectName.setEnabled(true);
                    if (!(path.lastIndexOf(File.separator) == path.length() - 1)) {
                        path.concat(File.separator);
                    }
                    StaticData.workspace = path;
                } else {
                    MessageBox messageBox;
                    messageBox = new MessageBox(shell, SWT.ERROR);
                    messageBox.setMessage("Given Path is Invalid");
                    messageBox.setText("Invalid Path Exception");
                    messageBox.open();
                }
            }
        }
    });
    textWrkspace.setEnabled(false);
    textWrkspace.setEditable(false);
    textWrkspace.setBounds(181, 5, 290, 23);

    final Button buttonWrkspace = new Button(group, SWT.NONE);
    buttonWrkspace.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {

            DirectoryDialog dialog = new DirectoryDialog(shell);
            String str = dialog.open();

            if (!str.equals("")) {
                txtProjectName.setEnabled(true);
                textWrkspace.setText(str);
                lalProjectWrkspace.setText(str);
            }
        }
    });
    buttonWrkspace.setText("Browse");
    buttonWrkspace.setEnabled(false);
    buttonWrkspace.setBounds(477, 5, 75, 25);

    Label label_1 = new Label(group, SWT.NONE);
    label_1.setText("Traceabilty Project Name");
    label_1.setBounds(0, 75, 175, 21);

    Group group_1 = new Group(shell, SWT.NONE);
    group_1.setText("Import Required Files");
    group_1.setBounds(20, 190, 556, 174);

    Label label_3 = new Label(group_1, SWT.NONE);
    label_3.setText("Requirement File");
    label_3.setBounds(10, 37, 137, 18);

    txtRequirementPath = new Text(group_1, SWT.BORDER);
    txtRequirementPath.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {

            if (!txtRequirementPath.getText().equals("")) {
                if (!txtUmlPath.getText().equals("") && !txtProjectPath.getText().equals("")
                        && !text_1.getText().equals("") && !text_2.getText().equals("")
                        && !text_3.getText().equals("") && !text_5.getText().equals("")
                        && !text_6.getText().equals("")) {
                    btnFinish.setEnabled(true);
                }
            } else {
                btnFinish.setEnabled(false);
            }
        }
    });
    txtRequirementPath.setEnabled(false);
    txtRequirementPath.setEditable(false);
    txtRequirementPath.setBounds(153, 31, 317, 27);

    btnReqBrwse = new Button(group_1, SWT.NONE);
    btnReqBrwse.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {

            org.eclipse.swt.widgets.FileDialog fileDialog = new org.eclipse.swt.widgets.FileDialog(shell,
                    SWT.SINGLE);
            fileDialog.setText("Open");
            fileDialog.setFilterExtensions(req_formats); // Windows
            fileDialog.setFilterPath(PropertyFile.docsFilePath);
            localFilePath = fileDialog.open();
            if (localFilePath != null) {
                PropertyFile.docsFilePath = localFilePath;
                txtRequirementPath.setText(PropertyFile.docsFilePath);
            }
        }
    });
    btnReqBrwse.setText("Browse");
    btnReqBrwse.setEnabled(false);
    btnReqBrwse.setBounds(476, 31, 75, 29);

    Label label_4 = new Label(group_1, SWT.NONE);
    label_4.setText("Design Diagram File");
    label_4.setBounds(10, 81, 137, 18);

    txtUmlPath = new Text(group_1, SWT.BORDER);
    txtUmlPath.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {

            if (!txtUmlPath.getText().equals("")) {
                if (!txtRequirementPath.getText().equals("") && !txtProjectPath.getText().equals("")
                        && !text_1.getText().equals("") && !text_2.getText().equals("")
                        && !text_3.getText().equals("") && !text_5.getText().equals("")
                        && !text_6.getText().equals("")) {
                    btnFinish.setEnabled(true);
                }
            } else {
                btnFinish.setEnabled(false);
            }

        }
    });
    txtUmlPath.setEnabled(false);
    txtUmlPath.setEditable(false);
    txtUmlPath.setBounds(153, 72, 317, 27);

    final Button btnUmlBrwse = new Button(group_1, SWT.NONE);
    btnUmlBrwse.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {

            org.eclipse.swt.widgets.FileDialog fileDialog = new org.eclipse.swt.widgets.FileDialog(shell,
                    SWT.MULTI);
            fileDialog.setText("Open");
            fileDialog.setFilterExtensions(uml_formats); // Windows
            fileDialog.setFilterPath(StaticData.umlFilePath);
            localFilePath = fileDialog.open();
            StaticData.umlFilePath = localFilePath;
            localFilePath = localFilePath.replace(Paths.get(localFilePath).getFileName().toString(), "");
            if (localFilePath != null) {
                txtUmlPath.setText(StaticData.umlFilePath);
            }
        }
    });
    btnUmlBrwse.setText("Browse");
    btnUmlBrwse.setEnabled(false);
    btnUmlBrwse.setBounds(476, 74, 75, 27);

    Label label_5 = new Label(group_1, SWT.NONE);
    label_5.setText("Project Path");
    label_5.setBounds(10, 126, 137, 18);

    txtProjectPath = new Text(group_1, SWT.BORDER);
    txtProjectPath.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            if (!txtProjectPath.getText().equals("")) {
                if (!txtRequirementPath.getText().equals("") && !txtUmlPath.getText().equals("")
                        && !text_1.getText().equals("") && !text_2.getText().equals("")
                        && !text_3.getText().equals("") && !text_5.getText().equals("")
                        && !text_6.getText().equals("")) {
                    btnFinish.setEnabled(true);
                }
            } else {
                btnFinish.setEnabled(false);
            }

        }
    });
    txtProjectPath.setEnabled(false);
    txtProjectPath.setEditable(false);
    txtProjectPath.setBounds(153, 120, 317, 27);

    final Button btnSrcBrwse = new Button(group_1, SWT.NONE);
    btnSrcBrwse.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {

            /*
             * Pop up File Chooser Window
             */
            DirectoryDialog directoryDialog = new DirectoryDialog(shell);
            directoryDialog.setText("Open");
            localFilePath = directoryDialog.open();
            StaticData.sourceFilePath = localFilePath;
            localFilePath = localFilePath.replace(Paths.get(localFilePath).getFileName().toString(), "");
            String root = "";// HomeGUI.tree.getToolTipText() +
                             // File.separator +
                             // txtProjectName.getText();
            String path = root + File.separator + FilePropertyName.SOURCE_CODE;
            srcJavaDir = new File(path);
            if (localFilePath != null) {
                txtProjectPath.setText(StaticData.sourceFilePath);
                boolean src = AccessProject.javaFilesExists(new File(StaticData.sourceFilePath.toString()));
                System.out.println("Java Files " + src);

                // &&!text_1.getText().equals("")&&!text_2.getText().equals("")&&!text_3.getText().equals("")&&!text_5.getText().equals("")&&!text_6.getText().equals("")
                if (src) {
                    if (!txtRequirementPath.getText().equals("") && !txtUmlPath.getText().equals("")) {

                        btnFinish.setEnabled(true);
                    }
                } else {
                    txtProjectPath.setText("");
                    // JOptionPane.showMessageDialog(null, "Error in java
                    // project file path...", "Java Project Error",
                    // JOptionPane.ERROR_MESSAGE);
                }
            }
        }
    });
    btnSrcBrwse.setText("Browse");
    btnSrcBrwse.setEnabled(false);
    btnSrcBrwse.setBounds(476, 120, 75, 27);

    final Button btnOk = new Button(group, SWT.NONE);
    btnOk.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            path_workspacepath = lalProjectWrkspace.getText();
            name_project = txtProjectName.getText();
            path_testfolder = path_workspacepath + File.separator + name_project;
            System.out.println(path_testfolder);
            try {
                FileUtils.forceMkdir(new File(path_testfolder));

            } catch (IOException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }

            String projectName = txtProjectName.getText();
            if (isNameValid(projectName)) {
                txtRequirementPath.setEnabled(true);
                txtUmlPath.setEnabled(true);
                txtProjectPath.setEnabled(true);
                text_1.setEnabled(true);
                text_2.setEnabled(true);
                text_3.setEnabled(true);
                text_5.setEnabled(true);
                text_6.setEnabled(true);

                btnReqBrwse.setEnabled(true);
                btnSrcBrwse.setEnabled(true);
                btnUmlBrwse.setEnabled(true);
                button.setEnabled(true);
                button_1.setEnabled(true);
                button_3.setEnabled(true);
                button_5.setEnabled(true);
                button_6.setEnabled(true);

            } else {
                /*
                 * name is not valid produce pop up message to user
                 * 
                 */
            }
        }
    });
    btnOk.setBounds(477, 67, 77, 29);
    btnOk.setText("Ok");
    Composite composite = new Composite(shell, SWT.NONE);
    composite.setBounds(20, 648, 556, 62);

    final Label lblNewLabel = new Label(composite, SWT.NONE);
    lblNewLabel.setBounds(24, 10, 459, 17);
    lblNewLabel.setText("");
    lblNewLabel.setForeground(new org.eclipse.swt.graphics.Color(Display.getCurrent(), 255, 0, 0));

    txtProjectName = new Text(group, SWT.BORDER);
    txtProjectName.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            //
            // File file = new
            // File(StaticData.workspace,txtProjectName.getText());
            // if(file.exists()){
            // btnOk.setEnabled(false);
            // }else{
            // btnOk.setEnabled(true);
            // }
        }

        @Override
        public void keyReleased(KeyEvent e) {

            File file = new File(StaticData.workspace, txtProjectName.getText());
            String typedName = txtProjectName.getText();
            boolean isProjectNameExists = isProjectExists(typedName);
            lblNewLabel.setText("");
            if (file.exists() || isProjectNameExists) {
                btnOk.setEnabled(false);

                txtRequirementPath.setEnabled(false);
                txtUmlPath.setEnabled(false);
                txtProjectPath.setEnabled(false);

                btnReqBrwse.setEnabled(false);
                btnSrcBrwse.setEnabled(false);
                btnUmlBrwse.setEnabled(false);

                btnFinish.setEnabled(false);

                if (!typedName.equals(""))
                    lblNewLabel.setText(
                            "You typed project name exists in " + allProjectsNamePathMap.get(typedName));
                else
                    lblNewLabel.setText("Project Name should not empty");
            } else {
                btnOk.setEnabled(true);
                lblNewLabel.setForeground(new org.eclipse.swt.graphics.Color(Display.getCurrent(), 255, 0, 0));
                lblNewLabel.setText("Project Name is valid");
            }
        }

        private boolean isProjectExists(String text) {
            // TODO Auto-generated method stub
            boolean isExits = false;
            if (allProjectsNamePathMap != null && allProjectsNamePathMap.containsKey(text)) {
                isExits = false;
            } else {
                // no need
                List<String> names = new ArrayList<>(allProjectsNamePathMap.keySet());
                for (String name : names) {
                    if (name.equals(text)) {
                        isExits = true;
                        return isExits;
                    }
                }
                isExits = false;
            }

            return isExits;
        }
    });
    txtProjectName.setText("");
    txtProjectName.setEnabled(true);
    txtProjectName.setBounds(182, 72, 278, 24);

    final Button btnNewWrkspace = new Button(group, SWT.CHECK);
    btnNewWrkspace.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {

            if (!btnNewWrkspace.getSelection()) {
                buttonWrkspace.setEnabled(false);
                textWrkspace.setEnabled(false);
                txtProjectName.setEnabled(true);
                btnOk.setEnabled(true);
            } else {
                buttonWrkspace.setEnabled(true);
                textWrkspace.setEnabled(true);
                txtProjectName.setEnabled(false);
                btnOk.setEnabled(false);
            }
        }
    });
    btnNewWrkspace.setText("Create New Workspace");
    btnNewWrkspace.setBounds(270, 34, 199, 24);

    button_2 = new Button(composite, SWT.NONE);
    button_2.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            shell.dispose();
        }
    });

    lblNewLabel.setText("");
    lblNewLabel.setForeground(new org.eclipse.swt.graphics.Color(Display.getCurrent(), 255, 0, 0));

    button_2.setText("Cancel");
    // button_2.setImage(SWTResourceManager.getImage("null"));
    button_2.setBounds(10, 29, 75, 25);

    btnFinish = new Button(composite, SWT.NONE);
    btnFinish.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {

            // MainClass mainClass = new
            // MainClass(text_5.getText(),text_6.getText());
            // mainClass.startConfig();
            //
            // Main m = new Main(text_1.getText(),text_2.getText());
            // m.startDeployment();
            //
            //
            // try {
            // TestAST testAST = new TestAST(text_3.getText());
            // testAST.TestingTraceability();
            // } catch (IOException e1) {
            // // TODO Auto-generated catch block
            // e1.printStackTrace();
            // } catch (TransformerException e1) {
            // // TODO Auto-generated catch block
            // e1.printStackTrace();
            // }
            //

            String projectName = txtProjectName.getText();

            // making script file for this project
            File file_root_script_folder = new File(PropertyFile.configuration_root + "scripts");
            if (!file_root_script_folder.exists())// home/shiyam/SAT_CONFIGS/scripts/
                file_root_script_folder.mkdirs(); // making script file for
            // each projects

            File script_file = FilePropertyName.createScriptFile(projectName + ".py");

            String scripts = ScriptContents.getContents(projectName);
            FilePropertyName.writeScriptContent(script_file, scripts);
            // finished the script file creation

            String reqFilePath = PropertyFile.docsFilePath;
            String umFilePath = StaticData.umlFilePath;
            String srcFilePath = StaticData.sourceFilePath;

            if (!(StaticData.workspace.lastIndexOf(File.separator) == StaticData.workspace.length() - 1)) {
                StaticData.workspace += (File.separator);
            }

            File projectRoot = new File(StaticData.workspace + projectName + File.separator);
            try {
                projectRoot.mkdir();
                ProjectCreateWindow.projectName = projectName;
            } catch (Exception e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
            File reqFile = new File(reqFilePath);
            File umlFile = new File(umFilePath);
            File srcFile = new File(srcFilePath);

            String projectAbsoulutePath = projectRoot.getAbsolutePath();
            System.out.println("!234");
            if (!(projectAbsoulutePath.lastIndexOf(File.separator) == projectAbsoulutePath.length() - 1)) {
                projectAbsoulutePath += (File.separator);
            }

            File srcFolder = new File(projectAbsoulutePath + FilePropertyName.SOURCE_CODE);
            try {
                srcFolder.mkdir();
                FilePropertyName.copyFolder(srcFile, srcFolder);

                File txtFolder = new File(projectAbsoulutePath + FilePropertyName.REQUIREMENT);
                txtFolder.mkdir();

                FilePropertyName.copyFile(reqFile, txtFolder);

                File umlFolder = new File(projectAbsoulutePath + FilePropertyName.UML);
                umlFolder.mkdir();

                FilePropertyName.copyFile(umlFile, umlFolder);

                File xmlFolder = new File(projectAbsoulutePath + FilePropertyName.XML);
                xmlFolder.mkdir();
                // PropertyFile.setRelationshipXMLPath(xmlFolder +
                // File.separator + FilePropertyName.RELATION_NAME);

                RelationManager.createXML(projectAbsoulutePath.substring(0, projectAbsoulutePath.length() - 1));
                // RelationManager.createXML(projectAbsoulutePath+FilePropertyName.XML);

                File propertyFolder = new File(projectAbsoulutePath + FilePropertyName.PROPERTY);
                propertyFolder.mkdir();

                // projectPath = PropertyFile.filePath + File.separator;
                projectPath = PropertyFile.filePath;
                System.out.println("---Project create window : line473 : " + projectPath);
                PropertyFile.setProjectName(projectName);
                PropertyFile.setGraphDbPath(projectPath + File.separator + FilePropertyName.PROPERTY
                        + File.separator + projectName + ".graphdb");
                PropertyFile.setGeneratedGexfFilePath(projectPath + File.separator + FilePropertyName.PROPERTY
                        + File.separator + projectName + ".gexf");
                PropertyFile.setRelationshipXMLPath(projectPath + "Relations.xml");

                HomeGUI.shell.setText("SAT- " + projectName);
                HomeGUI.newTab.setVisible(true);
                HomeGUI.tree.setVisible(true);

                System.out.println("---Project create window : line486 : " + projectPath);
                RelationManager.createXML(projectPath + projectName);

                /*
                 * write the sat_configuration.xml file with new project
                 * node and workspace node if needed
                 */
                Adapter.wrkspace = StaticData.workspace;
                Adapter.projectPath = StaticData.workspace + projectName;
                Adapter.createProjectNode();

                String temp = lalProjectWrkspace.getText().concat(File.separator);

                if (!temp.equals(StaticData.workspace)) {
                    StaticData.workspace = temp;
                    Adapter.createwrkpace("false");
                } else {
                    StaticData.workspace = temp;
                    Adapter.changeExistingWrkspaceStatus(StaticData.workspace, false);
                }
                System.out.println("Name: " + reqFilePath);
                // String[] names=reqFilePath.split(""+File.separator);
                // String requirementFileName=names[names.length-1];
                String requirementFileName = reqFilePath.substring(reqFilePath.lastIndexOf(File.separator));
                System.out.println("Re: " + requirementFileName);
                StaticData.requirementFilePath = projectAbsoulutePath + FilePropertyName.REQUIREMENT
                        + File.separator + requirementFileName;
                System.out
                        .println("----------Requirement file path--------- " + StaticData.requirementFilePath);

                Thread requirementThread = new Thread(new Runnable() {
                    public void run() {
                        try {
                            XMLConversion.convertRequirementFile();
                        } catch (Exception ex) {
                            Exceptions.printStackTrace(ex);
                        }
                    }
                });
                requirementThread.start();

                Thread javaFilesThread = new Thread(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            XMLConversion.convertJavaFiles();
                        } catch (Exception ex) {
                            Exceptions.printStackTrace(ex);
                        }
                    }
                });
                javaFilesThread.start();

                Thread umlThread = new Thread(new Runnable() {
                    @Override
                    public void run() {
                        XMLConversion.convertUMLFile();
                    }
                });
                umlThread.start();

                while (requirementThread.isAlive() || javaFilesThread.isAlive() || umlThread.isAlive()) {
                    StringBuilder aliveThread = new StringBuilder();
                    if (requirementThread.isAlive()) {
                        aliveThread.append("Requirement");
                        aliveThread.append(" ");
                    }
                    if (javaFilesThread.isAlive()) {
                        aliveThread.append("Source Code");
                        aliveThread.append(" ");
                    }
                    if (umlThread.isAlive()) {
                        aliveThread.append("UML");
                        aliveThread.append(" ");
                    }

                    lblNewLabel.setText(aliveThread.toString() + " Extraction On Progress");

                }
                System.out.println("Thread finished");
                /*
                 * XMLConversion.convertRequirementFile();
                 * XMLConversion.convertUMLFile();
                 * XMLConversion.convertJavaFiles();
                 */
                shell.dispose();
                HomeGUI.closeMain(HomeGUI.shell);
                HomeGUI.main(null);

            } catch (IOException e1) {
                displayError(e1.toString());
            } catch (Exception e12) {
                displayError(e12.toString());
                shell.dispose();
                HomeGUI.closeMain(HomeGUI.shell);
                HomeGUI.main(null);
            }
            // System.out.println("NLP OK...........");

        }

    });
    btnFinish.setText("Development");
    btnFinish.setEnabled(false);
    btnFinish.setBounds(471, 29, 75, 25);

    Button btnConfiguration = new Button(composite, SWT.NONE);
    btnConfiguration.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent arg0) {
            MainClass mainClass = new MainClass(text_5.getText(), text_6.getText());
            mainClass.startConfig();
            panels.put("config", config(configname));

            JTabbedPane pane = new JTabbedPane();
            pane.add("Config", panels.get("config"));

            if (panels.containsKey("test")) {
                pane.add("Test", panels.get("test"));
            }
            if (panels.containsKey("deploy")) {
                pane.add("Deploy", panels.get("deploy"));
            }
            frame1.remove(jTabbedPane);
            frame1.add(pane);
            jTabbedPane = pane;
            frame1.pack();
            frame1.setVisible(true);
        }
    });
    btnConfiguration.setText("Configuration");
    btnConfiguration.setEnabled(true);
    btnConfiguration.setBounds(120, 29, 94, 25);

    Button btnDeployment = new Button(composite, SWT.NONE);
    btnDeployment.setBounds(367, 29, 75, 25);
    btnDeployment.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent arg0) {
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            Main m = new Main(text_1.getText(), text_2.getText());
            m.startDeployment();

            panels.put("deploy", deploy(deployname));

            JTabbedPane pane = new JTabbedPane();
            pane.add("Deploy", panels.get("deploy"));

            if (panels.containsKey("test")) {
                pane.add("Test", panels.get("test"));
            }
            if (panels.containsKey("config")) {
                pane.add("Config", panels.get("config"));
            }
            frame1.remove(jTabbedPane);
            frame1.add(pane);
            jTabbedPane = pane;
            frame1.pack();
            frame1.setVisible(true);
        }
    });
    btnDeployment.setText("Deployment");
    btnDeployment.setEnabled(true);

    Button btnTesting = new Button(composite, SWT.NONE);
    btnTesting.setBounds(251, 29, 75, 25);
    btnTesting.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent arg0) {
            try {
                TestAST testAST = new TestAST(text_3.getText());
                testAST.TestingTraceability(path_testfolder);

                panels.put("test", test(testname));
                JTabbedPane pane = new JTabbedPane();
                pane.add("Test", panels.get("test"));

                if (panels.containsKey("config")) {
                    pane.add("Config", panels.get("config"));
                }
                if (panels.containsKey("deploy")) {
                    pane.add("Deploy", panels.get("deploy"));
                }

                frame1.remove(jTabbedPane);
                frame1.add(pane);
                jTabbedPane = pane;
                frame1.pack();
                frame1.setVisible(true);

            } catch (IOException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            } catch (TransformerException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
        }
    });
    btnTesting.setText("Testing");
    btnTesting.setEnabled(true);

    Label label_6 = new Label(shell, SWT.NONE);
    label_6.setText("New project will be created ");
    label_6.setBounds(20, 10, 189, 17);

    Group grpExetendedSatAnalizer = new Group(shell, SWT.NONE);
    grpExetendedSatAnalizer.setText("Exetended SAT Analizer");
    grpExetendedSatAnalizer.setBounds(20, 370, 556, 272);

    Label lblDeploymentDiagramFile = new Label(grpExetendedSatAnalizer, SWT.NONE);
    lblDeploymentDiagramFile.setText("Deployment Diagram File");
    lblDeploymentDiagramFile.setBounds(10, 34, 137, 18);

    text_1 = new Text(grpExetendedSatAnalizer, SWT.BORDER);
    text_1.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {

            if (!text_1.getText().equals("")) {
                if (!txtUmlPath.getText().equals("") && !txtProjectPath.getText().equals("")
                        && !txtRequirementPath.getText().equals("") && !text_2.getText().equals("")
                        && !text_3.getText().equals("") && !text_5.getText().equals("")
                        && !text_6.getText().equals("")) {
                    btnFinish.setEnabled(true);
                }
            } else {
                btnFinish.setEnabled(false);
            }
        }
    });
    text_1.setEnabled(false);
    text_1.setEditable(false);
    text_1.setBounds(153, 28, 317, 27);

    button = new Button(grpExetendedSatAnalizer, SWT.NONE);
    button.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {

            org.eclipse.swt.widgets.FileDialog fileDialog = new org.eclipse.swt.widgets.FileDialog(shell,
                    SWT.SINGLE);
            fileDialog.setText("Open");
            fileDialog.setFilterExtensions(all_formats); // Windows
            fileDialog.setFilterPath(PropertyFile.docsFilePath);
            localFilePath = fileDialog.open();
            if (localFilePath != null) {
                // PropertyFile.docsFilePath = localFilePath;
                text_1.setText(localFilePath);
            }
        }
    });
    button.setText("Browse");
    button.setEnabled(false);
    button.setBounds(476, 30, 75, 27);

    Label lblDockerFile = new Label(grpExetendedSatAnalizer, SWT.NONE);
    lblDockerFile.setText("Docker File");
    lblDockerFile.setBounds(10, 79, 137, 18);

    text_2 = new Text(grpExetendedSatAnalizer, SWT.BORDER);
    text_2.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {

            if (!text_2.getText().equals("")) {
                if (!txtUmlPath.getText().equals("") && !txtProjectPath.getText().equals("")
                        && !txtRequirementPath.getText().equals("") && !text_1.getText().equals("")
                        && !text_3.getText().equals("") && !text_5.getText().equals("")
                        && !text_6.getText().equals("")) {
                    btnFinish.setEnabled(true);
                }
            } else {
                btnFinish.setEnabled(false);
            }
        }
    });
    text_2.setEnabled(false);
    text_2.setEditable(false);
    text_2.setBounds(153, 73, 317, 27);

    button_1 = new Button(grpExetendedSatAnalizer, SWT.NONE);
    button_1.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {

            org.eclipse.swt.widgets.FileDialog fileDialog = new org.eclipse.swt.widgets.FileDialog(shell,
                    SWT.SINGLE);
            fileDialog.setText("Open");
            fileDialog.setFilterExtensions(all_formats); // Windows
            fileDialog.setFilterPath(PropertyFile.docsFilePath);
            localFilePath = fileDialog.open();
            if (localFilePath != null) {
                // PropertyFile.docsFilePath = localFilePath;
                text_2.setText(localFilePath);
            }
        }
    });
    button_1.setText("Browse");
    button_1.setEnabled(false);
    button_1.setBounds(476, 75, 75, 27);

    Label lblTestCases = new Label(grpExetendedSatAnalizer, SWT.NONE);
    lblTestCases.setText("Test case Path");
    lblTestCases.setBounds(10, 124, 137, 18);

    text_3 = new Text(grpExetendedSatAnalizer, SWT.BORDER);
    text_3.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {

            if (!text_3.getText().equals("")) {
                if (!txtUmlPath.getText().equals("") && !txtProjectPath.getText().equals("")
                        && !txtRequirementPath.getText().equals("") && !text_1.getText().equals("")
                        && !text_2.getText().equals("") && !text_5.getText().equals("")
                        && !text_6.getText().equals("")) {
                    btnFinish.setEnabled(true);
                }
            } else {
                btnFinish.setEnabled(false);
            }
        }
    });
    text_3.setEnabled(false);
    text_3.setEditable(false);
    text_3.setBounds(153, 118, 317, 27);

    button_3 = new Button(grpExetendedSatAnalizer, SWT.NONE);
    button_3.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {

            /*
             * Pop up File Chooser Window
             */
            DirectoryDialog directoryDialog = new DirectoryDialog(shell);
            directoryDialog.setText("Open");
            localFilePath = directoryDialog.open();
            StaticData.sourceFilePath = localFilePath;
            localFilePath = localFilePath.replace(Paths.get(localFilePath).getFileName().toString(), "");
            String root = "";// HomeGUI.tree.getToolTipText() +
                             // File.separator +
                             // txtProjectName.getText();
            String path = root + File.separator + FilePropertyName.SOURCE_CODE;
            srcJavaDir = new File(path);
            if (localFilePath != null) {
                text_3.setText(localFilePath);
                boolean src = AccessProject.javaFilesExists(new File(StaticData.sourceFilePath.toString()));
                System.out.println("Test Java Files " + src);

            }
        }
    });
    button_3.setText("Browse");
    button_3.setEnabled(false);
    button_3.setBounds(476, 120, 75, 27);

    Label lblPropertyFile = new Label(grpExetendedSatAnalizer, SWT.NONE);
    lblPropertyFile.setText("Property File");
    lblPropertyFile.setBounds(10, 173, 137, 18);

    text_5 = new Text(grpExetendedSatAnalizer, SWT.BORDER);
    text_5.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {

            if (!text_5.getText().equals("")) {
                if (!txtUmlPath.getText().equals("") && !txtProjectPath.getText().equals("")
                        && !txtRequirementPath.getText().equals("") && !text_1.getText().equals("")
                        && !text_2.getText().equals("") && !text_3.getText().equals("")
                        && !text_6.getText().equals("")) {
                    btnFinish.setEnabled(true);
                }
            } else {
                btnFinish.setEnabled(false);
            }
        }
    });
    text_5.setEnabled(false);
    text_5.setEditable(false);
    text_5.setBounds(153, 167, 317, 27);
    button_5 = new Button(grpExetendedSatAnalizer, SWT.NONE);

    button_5.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {

            org.eclipse.swt.widgets.FileDialog fileDialog = new org.eclipse.swt.widgets.FileDialog(shell,
                    SWT.SINGLE);
            fileDialog.setText("Open");
            fileDialog.setFilterExtensions(config_formats); // Windows
            fileDialog.setFilterPath(PropertyFile.docsFilePath);
            localFilePath = fileDialog.open();
            if (localFilePath != null) {
                // PropertyFile.docsFilePath = localFilePath;
                text_5.setText(localFilePath);
            }
        }
    });
    button_5.setText("Browse");
    button_5.setEnabled(false);
    button_5.setBounds(476, 169, 75, 27);

    Label lblConfigurationFile = new Label(grpExetendedSatAnalizer, SWT.NONE);
    lblConfigurationFile.setText("Configuration Text File");
    lblConfigurationFile.setBounds(10, 208, 137, 18);

    text_6 = new Text(grpExetendedSatAnalizer, SWT.BORDER);
    text_6.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {

            if (!text_6.getText().equals("")) {
                if (!txtUmlPath.getText().equals("") && !txtProjectPath.getText().equals("")
                        && !txtRequirementPath.getText().equals("") && !text_1.getText().equals("")
                        && !text_2.getText().equals("") && !text_3.getText().equals("")
                        && !text_5.getText().equals("")) {
                    btnFinish.setEnabled(true);
                }
            } else {
                btnFinish.setEnabled(false);
            }
        }
    });
    text_6.setEnabled(false);
    text_6.setEditable(false);
    text_6.setBounds(153, 202, 317, 27);

    button_6 = new Button(grpExetendedSatAnalizer, SWT.NONE);
    button_6.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {

            org.eclipse.swt.widgets.FileDialog fileDialog = new org.eclipse.swt.widgets.FileDialog(shell,
                    SWT.SINGLE);
            fileDialog.setText("Open");
            fileDialog.setFilterExtensions(req_formats); // Windows
            fileDialog.setFilterPath(PropertyFile.docsFilePath);
            localFilePath = fileDialog.open();
            if (localFilePath != null) {
                // PropertyFile.docsFilePath = localFilePath;
                text_6.setText(localFilePath);
            }
        }
    });
    button_6.setText("Browse");
    button_6.setEnabled(false);
    button_6.setBounds(476, 204, 75, 27);

}

From source file:azkaban.execapp.FlowRunnerTest2.java

/**
 * Test the condition for a manual invocation of a KILL (cancel) on a flow
 * that has been paused. The flow should unpause and be killed immediately.
 *
 * @throws Exception/*from w w  w.j  a  v  a2s .c om*/
 */
@Ignore
@Test
public void testPauseKill() throws Exception {
    EventCollectorListener eventCollector = new EventCollectorListener();
    FlowRunner runner = createFlowRunner(eventCollector, "jobf");

    Map<String, Status> expectedStateMap = new HashMap<String, Status>();
    Map<String, ExecutableNode> nodeMap = new HashMap<String, ExecutableNode>();

    // 1. START FLOW
    ExecutableFlow flow = runner.getExecutableFlow();
    createExpectedStateMap(flow, expectedStateMap, nodeMap);
    Thread thread = runFlowRunnerInThread(runner);
    pause(250);

    // After it starts up, only joba should be running
    expectedStateMap.put("joba", Status.RUNNING);
    expectedStateMap.put("joba1", Status.RUNNING);
    compareStates(expectedStateMap, nodeMap);

    // 2. JOB A COMPLETES SUCCESSFULLY
    InteractiveTestJob.getTestJob("joba").succeedJob();
    pause(250);
    expectedStateMap.put("joba", Status.SUCCEEDED);
    expectedStateMap.put("joba1", Status.RUNNING);
    expectedStateMap.put("jobb", Status.RUNNING);
    expectedStateMap.put("jobc", Status.RUNNING);
    expectedStateMap.put("jobd", Status.RUNNING);
    expectedStateMap.put("jobd:innerJobA", Status.RUNNING);
    expectedStateMap.put("jobb:innerJobA", Status.RUNNING);
    compareStates(expectedStateMap, nodeMap);

    runner.pause("me");
    pause(250);
    Assert.assertEquals(flow.getStatus(), Status.PAUSED);
    InteractiveTestJob.getTestJob("jobb:innerJobA").succeedJob();
    InteractiveTestJob.getTestJob("jobd:innerJobA").succeedJob();
    pause(250);
    expectedStateMap.put("jobb:innerJobA", Status.SUCCEEDED);
    expectedStateMap.put("jobd:innerJobA", Status.SUCCEEDED);
    compareStates(expectedStateMap, nodeMap);

    runner.kill("me");
    pause(250);
    expectedStateMap.put("joba1", Status.KILLED);
    expectedStateMap.put("jobb:innerJobB", Status.CANCELLED);
    expectedStateMap.put("jobb:innerJobC", Status.CANCELLED);
    expectedStateMap.put("jobb:innerFlow", Status.CANCELLED);
    expectedStateMap.put("jobb", Status.KILLED);
    expectedStateMap.put("jobc", Status.KILLED);
    expectedStateMap.put("jobd:innerFlow2", Status.CANCELLED);
    expectedStateMap.put("jobd", Status.KILLED);
    expectedStateMap.put("jobe", Status.CANCELLED);
    expectedStateMap.put("jobf", Status.CANCELLED);

    compareStates(expectedStateMap, nodeMap);
    Assert.assertEquals(Status.KILLED, flow.getStatus());
    Assert.assertFalse(thread.isAlive());
}