Java Code Examples for org.openide.windows.InputOutput#closeInputOutput()

The following examples show how to use org.openide.windows.InputOutput#closeInputOutput() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExecutionEngine.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Should prepare environment for Executor and start it. Is called from
* Executor.execute method.
*
* @param executor to start
* @param info about class to start
*/
public ExecutorTask execute(String name, Runnable run, final InputOutput inout) {
    TaskThreadGroup g = new TaskThreadGroup(base, "exec_" + name + "_" + number); // NOI18N
    g.setDaemon(true);
    ExecutorTaskImpl task = new ExecutorTaskImpl();
    synchronized (task.lock) {
        try {
            new RunClassThread(g, name, number++, inout, this, task, run);
            task.lock.wait();
        } catch (InterruptedException e) { // #171795
            inout.closeInputOutput();
            return new ExecutorTask(null) {
                public @Override void stop() {}
                public @Override int result() {return 2;}
                public @Override InputOutput getInputOutput() {return inout;}
            };
        }
    }
    return task;
}
 
Example 2
Source File: T3_HardClose_Test.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testNotReusable() {
System.out.printf("testNotReusabele()\r");

InputOutput ioRef = io;
io.closeInputOutput();

// because closeInputOutput() gets posted to run on the EDT
// it effect isn't immediate.
// W/o this sleep() both terminal and default IO will end up
// reusing because the close operation hasn't gone through.
sleep(1);

boolean reuse = true;
InputOutput uniqueIO = ioProvider.getIO("test", !reuse);
assertTrue("hard closed io got reused", ioRef != uniqueIO);

// cleanup
uniqueIO.closeInputOutput();
   }
 
Example 3
Source File: OutputTabMaintainer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected final InputOutput createInputOutput() {
    if (MavenSettings.getDefault().isReuseOutputTabs()) {
        synchronized (freeTabs) {
            for (Map.Entry<InputOutput,AllContext<?>> entry : freeTabs.entrySet()) {
                InputOutput free = entry.getKey();
                AllContext<?> allContext = entry.getValue();
                if (io == null && allContext.name.equals(name) && allContext.tabContextType == tabContextType()) {
                    // Reuse it.
                    io = free;
                    reassignAdditionalContext(tabContextType().cast(allContext.tabContext));
                    try {
                        io.getOut().reset();
                    } catch (IOException ex) {
                        ex.printStackTrace();
                    }
                    // useless: io.flushReader();
                } else {
                    // Discard it.
                    free.closeInputOutput();
                }
            }
            freeTabs.clear();
        }
    }
    //                }
    if (io == null) {
        io = IOProvider.getDefault().getIO(name, createNewTabActions());
        io.setInputVisible(true);
    }
    return io;
}
 
Example 4
Source File: NbIOProviderTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetIO_4args() {

    IOContainer def = IOContainer.getDefault();
    IOContainer cus = IOContainer.create(new MyContainerProvider());

    InputOutput ioDef1 = IOProvider.getDefault().getIO("test1", true, null, def);
    InputOutput ioCus1 = IOProvider.getDefault().getIO("test1", true, null, cus);
    InputOutput ioDef2 = IOProvider.getDefault().getIO("test2", true, null, def);
    InputOutput ioCus2 = IOProvider.getDefault().getIO("test2", true, null, cus);

    assertNotSame(ioDef1, ioCus1);
    assertNotSame(ioDef2, ioCus2);
    assertNotSame(ioDef1, ioDef2);
    assertNotSame(ioCus1, ioCus2);

    InputOutput ioDef1b = IOProvider.getDefault().getIO("test1", false, null, def);
    InputOutput ioCus1b = IOProvider.getDefault().getIO("test1", false, null, cus);

    assertSame(ioDef1, ioDef1b);
    assertSame(ioCus1, ioCus1b);

    ioDef1.closeInputOutput();
    ioDef2.closeInputOutput();
    ioCus1.closeInputOutput();
    ioCus2.closeInputOutput();
}
 
Example 5
Source File: OutputTabMaintainer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected final InputOutput createInputOutput() {
    if (GradleSettings.getDefault().isReuseOutputTabs()) {
        synchronized (FREE_TABS) {
            for (Map.Entry<InputOutput,AllContext<?>> entry : FREE_TABS.entrySet()) {
                InputOutput free = entry.getKey();
                AllContext<?> allContext = entry.getValue();
                if (io == null && allContext.name.equals(name) && allContext.tabContextType == tabContextType()) {
                    // Reuse it.
                    io = free;
                    reassignAdditionalContext(tabContextType().cast(allContext.tabContext));
                    try {
                        io.getOut().reset();
                    } catch (IOException ex) {
                        ex.printStackTrace();
                    }
                    // useless: io.flushReader();
                } else {
                    // Discard it.
                    free.closeInputOutput();
                }
            }
            FREE_TABS.clear();
        }
    }
    //                }
    if (io == null) {
        io = IOProvider.getDefault().getIO(name, createNewTabActions());
        io.setInputVisible(true);
    }
    return io;
}
 
Example 6
Source File: PayaraInstance.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
    public void remove() {
        // Just in case...
        if(!removable) {
            return;
        }
        
        // !PW FIXME Remove debugger hooks, if any
//        DebuggerManager.getDebuggerManager().removeDebuggerListener(debuggerStateListener);

        stopIfStartedByIde(3000L);
        
        // close the server io window
        String uri = getDeployerUri();
        InputOutput io = LogViewMgr.getServerIO(uri);
        if(io != null && !io.isClosed()) {
            io.closeInputOutput();
        }

        Collection<? extends RemoveCookie> lookupAll = localLookup.lookupAll(RemoveCookie.class);
        for(RemoveCookie cookie: lookupAll) {
            cookie.removeInstance(getDeployerUri());
        }

        instanceProvider.removeServerInstance(this);
        ic.remove(this);
    }
 
Example 7
Source File: GlassfishInstance.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
    public void remove() {
        // Just in case...
        if(!removable) {
            return;
        }
        
        // !PW FIXME Remove debugger hooks, if any
//        DebuggerManager.getDebuggerManager().removeDebuggerListener(debuggerStateListener);

        stopIfStartedByIde(3000L);
        
        // close the server io window
        String uri = getDeployerUri();
        InputOutput io = LogViewMgr.getServerIO(uri);
        if(io != null && !io.isClosed()) {
            io.closeInputOutput();
        }

        Collection<? extends RemoveCookie> lookupAll = localLookup.lookupAll(RemoveCookie.class);
        for(RemoveCookie cookie: lookupAll) {
            cookie.removeInstance(getDeployerUri());
        }

        instanceProvider.removeServerInstance(this);
        ic.remove(this);
    }
 
Example 8
Source File: ServerInstance.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Remove this server instance and stop it if it has been started from within the IDE */
public void remove() {
    DebuggerManager.getDebuggerManager().removeDebuggerListener(debuggerStateListener);
    stopIfStartedByIde();        
    // close the server io window
    if (getUrl() != null) {
        InputOutput io = UISupport.getServerIO(url);
        if (io != null && !io.isClosed()) {
            io.closeInputOutput();
        }
        ServerRegistry.getInstance().removeServerInstance(getUrl());
    } else {
        LOGGER.log(Level.WARNING, "Trying to remove {0}, but url is null", server != null ? server.getShortName() : null);
    }
}
 
Example 9
Source File: T1_Close_Test.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testTitle() {

	testTitleHelp(io);
	InputOutput io1 = ioProvider.getIO("io1", null, ioContainer);
	io1.select();
	testTitleHelp(io1);
	io1.closeInputOutput();
    }
 
Example 10
Source File: BridgingInputOutputProvider.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public void closeIO(InputOutput io) {
    io.closeInputOutput();
}
 
Example 11
Source File: NbIOProvider.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public void closeIO(InputOutput io) {
    io.closeInputOutput();
}
 
Example 12
Source File: RunCheckerImpl.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void closeInputOuptut(ExecutionContext context) {
    InputOutput ioput = context.getInputOutput();
    if (ioput != null) {
        ioput.closeInputOutput();
    }
}