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

The following examples show how to use org.openide.windows.InputOutput#isClosed() . 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: InputOutputCache.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static CachedInputOutput get(InputOutput inputOutput) {
    CachedInputOutput result = null;

    synchronized (InputOutputCache.class) {
        for (Iterator<Entry<InputOutput, CachedInputOutput>> it = AVAILABLE.entrySet().iterator(); it.hasNext();) {
            Entry<InputOutput, CachedInputOutput> entry = it.next();

            final InputOutput free = entry.getKey();
            final CachedInputOutput data = entry.getValue();

            if (free.isClosed()) {
                it.remove();
                continue;
            }

            if (free.equals(inputOutput)) {
                result = data;
                ACTIVE_DISPLAY_NAMES.add(result.getDisplayName());
                it.remove();
            }
            LOGGER.log(Level.FINEST, "Pooled: {0}", data.getDisplayName());
        }
    }
    return result;
}
 
Example 2
Source File: InputOutputManager.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static InputOutputData getInputOutput(InputOutput inputOutput) {
    InputOutputData result = null;

    synchronized (InputOutputManager.class) {
        for (Iterator<Entry<InputOutput, InputOutputData>> it = AVAILABLE.entrySet().iterator(); it.hasNext();) {
            Entry<InputOutput, InputOutputData> entry = it.next();

            final InputOutput free = entry.getKey();
            final InputOutputData data = entry.getValue();

            if (free.isClosed()) {
                it.remove();
                continue;
            }

            if (free.equals(inputOutput)) {
                result = data;
                ACTIVE_DISPLAY_NAMES.add(result.displayName);
                it.remove();
            }
            LOGGER.log(Level.FINEST, "InputOutputManager pool: {0}", data.getDisplayName());
        }
    }
    return result;
}
 
Example 3
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 4
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 5
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 6
Source File: InputOutputManager.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Tries to find free Output Window tab for the given name.
 *
 * @param name the name of the free tab. Other free tabs are ignored.
 * @return free tab and its current display name or <tt>null</tt>
 */
public static InputOutputData getInputOutput(String name, boolean actions, String optionsPath) {
    InputOutputData result = null;

    TreeSet<InputOutputData> candidates = new TreeSet<InputOutputData>(InputOutputData.DISPLAY_NAME_COMPARATOR);

    synchronized (InputOutputManager.class) {
        for (Iterator<Entry<InputOutput, InputOutputData>> it = AVAILABLE.entrySet().iterator(); it.hasNext();) {
            Entry<InputOutput, InputOutputData> entry = it.next();

            final InputOutput free = entry.getKey();
            final InputOutputData data = entry.getValue();

            if (free.isClosed()) {
                it.remove();
                continue;
            }

            if (isAppropriateName(name, data.displayName)) {
                if ((actions && data.rerunAction != null && data.stopAction != null)
                        || !actions && data.rerunAction == null && data.stopAction == null) {
                    if (optionsPath != null && data.optionsAction != null && data.optionsAction.getOptionsPath().equals(optionsPath)
                            || optionsPath == null && data.optionsAction == null) {
                        // Reuse it.
                        candidates.add(data);
                    }
                } // continue to remove all closed tabs
            }

            LOGGER.log(Level.FINEST, "InputOutputManager pool: {0}", data.getDisplayName());
        }

        if (!candidates.isEmpty()) {
            result = candidates.first();
            AVAILABLE.remove(result.inputOutput);
            ACTIVE_DISPLAY_NAMES.add(result.displayName);
        }
    }
    return result;
}
 
Example 7
Source File: BridgingInputOutputProvider.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isIOClosed(InputOutput io) {
    return io.isClosed();
}
 
Example 8
Source File: NbIOProvider.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isIOClosed(InputOutput io) {
    return io.isClosed();
}
 
Example 9
Source File: InputOutputCache.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private static CachedInputOutput getInputOutput(String name, List<Action> actions) {
    CachedInputOutput result = null;

    TreeSet<CachedInputOutput> candidates = new TreeSet<>(CachedInputOutput.DISPLAY_NAME_COMPARATOR);

    synchronized (InputOutputCache.class) {
        for (Iterator<Entry<InputOutput, CachedInputOutput>> it = AVAILABLE.entrySet().iterator(); it.hasNext();) {
            Entry<InputOutput, CachedInputOutput> entry = it.next();

            final InputOutput free = entry.getKey();
            final CachedInputOutput data = entry.getValue();

            if (free.isClosed()) {
                it.remove();
                continue;
            }

            if (isAppropriateName(name, data.getDisplayName())) {
                List<Action> candidateActions = data.getActions();
                if (candidateActions.isEmpty() && (actions == null || actions.isEmpty())) {
                    candidates.add(data);
                } else if (actions != null && candidateActions.size() == actions.size()) {
                    boolean differs = false;
                    for (int i = 0; i < candidateActions.size(); i++) {
                        if (candidateActions.get(i).getClass() != actions.get(i).getClass()) {
                            differs = true;
                            break;
                        }
                    }
                    if (!differs) {
                        candidates.add(data);
                    }
                } // continue to remove all closed tabs
            }

            LOGGER.log(Level.FINEST, "Pooled: {0}", data.getDisplayName());
        }

        if (!candidates.isEmpty()) {
            result = candidates.first();
            AVAILABLE.remove(result.getInputOutput());
            ACTIVE_DISPLAY_NAMES.add(result.getDisplayName());
        }
    }
    return result;
}
 
Example 10
Source File: LogViewer.java    From netbeans with Apache License 2.0 2 votes vote down vote up
/**
 * Tests whether LogViewer thread is still running.
 * @return <code>false</code> if thread was stopped or its output window
 * was closed, <code>true</code> otherwise.
 */
public boolean isOpen() {
    InputOutput io = inOut;
    return !(io == null || stop || (isStarted && io.isClosed()));
}