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

The following examples show how to use org.openide.windows.InputOutput#select() . 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: DebuggerChecker.java    From netbeans with Apache License 2.0 6 votes vote down vote up
protected void doReload(final RunConfig config, final String cname) {
    DebuggerTabMaintainer otm = getOutputTabMaintainer(config.getExecutionName());
    
    InputOutput io = otm.getInputOutput();
    io.select();
    OutputWriter ow = io.getOut();
    try {
        ow.reset();
    } catch (IOException ex) { }
    
    try {
        reload(config.getProject(), ow, cname);
    } finally {
        io.getOut().close();
        otm.markTab();
    }
}
 
Example 2
Source File: ExecutionService.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Configures the output window before usage.
 *
 * @param inputOutput output window to configure
 */
private void configureInputOutput(InputOutput inputOutput) {
    if (inputOutput == InputOutput.NULL) {
        return;
    }

    if (descriptor.getInputOutput() == null || !descriptor.noReset()) {
        try {
            inputOutput.getOut().reset();
        } catch (IOException exc) {
            LOGGER.log(Level.INFO, null, exc);
        }

        // Note - do this AFTER the reset() call above; if not, weird bugs occur
        inputOutput.setErrSeparated(false);
    }

    // Open I/O window now. This should probably be configurable.
    if (descriptor.isFrontWindow()) {
        inputOutput.select();
    }

    inputOutput.setInputVisible(descriptor.isInputVisible());
}
 
Example 3
Source File: SaveEGTask.java    From BART with MIT License 6 votes vote down vote up
@Override
    public void save() throws IOException {
        dto = CentralLookup.getDefLookup().lookup(EGTaskDataObjectDataObject.class);
        final InputOutput io = IOProvider.getDefault().getIO(dto.getPrimaryFile().getName(), false);
        io.select();
        OutputWindow.openOutputWindowStream(io.getOut(), io.getErr());
        final Dialog d = BusyDialog.getBusyDialog();
        RequestProcessor.Task T = RequestProcessor.getDefault().post(new SaveEgtaskRunnable());
        T.addTaskListener(new TaskListener() {

            @Override
            public void taskFinished(Task task) {
//                d.setVisible(false);
                if(esito)   {
                    System.out.println(Bundle.MSG_SaveEGTask_OK(dto.getPrimaryFile().getName()));
                }else{
                    System.err.println(Bundle.MSG_SaveEGTask_Failed(dto.getPrimaryFile().getName()));                  
                }
                OutputWindow.closeOutputWindowStream(io.getOut(), io.getErr());
//                d.setVisible(false);
            }
            
        });
//        d.setVisible(true);
    }
 
Example 4
Source File: WildflyStartServer.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private InputOutput openConsole() {
    InputOutput io = UISupport.getServerIO(dm.getUrl());
    if (io == null) {
        return null; // finish, it looks like this server instance has been unregistered
    }

    // clear the old output
    try {
        io.getOut().reset();
    } catch (IOException ioe) {
        // no op
    }
    io.select();

    return io;
}
 
Example 5
Source File: SearchDisplayer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 */
void prepareOutput() {
    String tabName = NbBundle.getMessage(ResultView.class,
                                         "TITLE_SEARCH_RESULTS");   //NOI18N
    InputOutput searchIO = IOProvider.getDefault().getIO(tabName, false);
    ow = searchIO.getOut();
    owRef = new WeakReference<OutputWriter>(ow);
    
    searchIO.select();
}
 
Example 6
Source File: T5_MTStress_Test.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
    * Create one IO and many writers write to it in parallel.
    */
   public void testMultiWriter() {
System.out.printf("testMultiWriter()\n");

final InputOutput iot = ioProvider.getIO("test2", null, ioContainer);
iot.select();
sleep(1);

Thread threads[] = new Thread[NWRITERS];
for (int tx = 0; tx < NWRITERS; tx++) {
    final int tn = tx;
    Thread t = new Thread(new Runnable() {
	@Override
	public void run() {
	    OutputWriter ow = iot.getOut();
	    exercise(iot, ow, 50);
	}
    });
    threads[tx] = t;
    t.start();
}

for (int tx = 0; tx < NWRITERS; tx++) {
    try {
	threads[tx].join();
    } catch (InterruptedException ex) {
	Exceptions.printStackTrace(ex);
    }
}
   }
 
Example 7
Source File: OutputUtils.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static void focusTerminal(InputOutput io) {
    io.select();
    if (IOTerm.isSupported(io)) {
        // XXX is there a better way ?
         IOTerm.requestFocus(io);            
    }
}
 
Example 8
Source File: ReloadDependencies.java    From BART with MIT License 5 votes vote down vote up
@Override// closeDependencyViewTopComponent
    public void actionPerformed(ActionEvent ev) {
        if(dto == null || dto.getEgtask() == null)return;       
        if(textPanel.getText().isEmpty())return;
        if((egtask.getTarget() == null) || (egtask.getTarget() instanceof EmptyDB))   {
                DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(
                        Bundle.MSG_ReloadDependenciesNoDBTarget(), 
                        NotifyDescriptor.INFORMATION_MESSAGE));
            return;
        }   
        final InputOutput io = IOProvider.getDefault().getIO(dto.getPrimaryFile().getName(), false);
        io.select();
        OutputWindow.openOutputWindowStream(io.getOut(), io.getErr());
        final Dialog d = BusyDialog.getBusyDialog();
        RequestProcessor.Task T = RequestProcessor.getDefault().post(new reloadDependeciesRunnable());
        T.addTaskListener(new TaskListener() {
            @Override
            public void taskFinished(Task task) {
//                d.setVisible(false);
                if(esito)   {     
                    dto.setEgtModified(true);
                    StatusBar.setStatus(Bundle.MSG_ReloadDependenciesExecuted(), 10,5000);
                    System.out.println(Bundle.MSG_ReloadDependenciesExecuted());
                    DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(
                            Bundle.MSG_ReloadDependenciesExecuted(), 
                            NotifyDescriptor.INFORMATION_MESSAGE));
                }else{
                    System.err.println(Bundle.MSG_ReloadDependenciesException());
                    StatusBar.setStatus(Bundle.MSG_ReloadDependenciesExecuted(), 10,5000);
                }
                OutputWindow.closeOutputWindowStream(io.getOut(), io.getErr());
            }
        });
//        d.setVisible(true);
    }
 
Example 9
Source File: OpenServerLogAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected void performAction(Node[] activatedNodes) {
    for (Node activatedNode : activatedNodes) {
        Object node = activatedNode.getLookup().lookup(JBManagerNode.class);
        
        if (!(node instanceof JBManagerNode)) {
            continue;
        }
        
        JBDeploymentManager dm = ((JBManagerNode)node).getDeploymentManager();
        InputOutput io = UISupport.getServerIO(dm.getUrl());
        if (io != null) {
            io.select();
        }
        
        InstanceProperties ip = dm.getInstanceProperties();
        JBOutputSupport outputSupport = JBOutputSupport.getInstance(ip, false);
        if (outputSupport == null) {
            outputSupport = JBOutputSupport.getInstance(ip, true);
            String serverDir = ip.getProperty(JBPluginProperties.PROPERTY_SERVER_DIR);
            String logFileName = serverDir + File.separator + "log" + File.separator + "server.log" ; // NOI18N
            File logFile = new File(logFileName);
            if (logFile.exists()) {
                outputSupport.start(io, logFile);
            }                
        }
    }        
}
 
Example 10
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 11
Source File: T4_Attribute_Test.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testFirstTab() {
System.out.printf("testFirstTab()\n");

io.select();
sleep(1);	// give select time to take effect

setAttrs();
sleep(1);	// give them time to take effect

InputOutput io2 = ioProvider.getIO("test2", null, ioContainer);
assertNotNull ("Could not get InputOutput", io2);
io2.select();
sleep(1);	// give select time to take effect
   }
 
Example 12
Source File: RemoteCommand.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static InputOutput getRemoteLog(String displayName, boolean select) {
    InputOutput io = IOProvider.getDefault().getIO(NbBundle.getMessage(Command.class, "LBL_RemoteLog", displayName), false);
    if (select) {
        io.select();
    }
    try {
        io.getOut().reset();
    } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
    }
    return io;
}
 
Example 13
Source File: T4_Attribute_Test.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testSecondTab() {
System.out.printf("testSecondTab()\n");

io.select();
sleep(1);	// give select time to take effect

InputOutput io2 = ioProvider.getIO("test2", null, ioContainer);
assertNotNull ("Could not get InputOutput", io2);
io2.select();
sleep(1);	// give select time to take effect

setAttrs();
sleep(1);	// give them time to take effect
   }
 
Example 14
Source File: OpenServerLogAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
protected void performAction(Node[] activatedNodes) {
    for (Node activatedNode : activatedNodes) {
        Object node = activatedNode.getLookup().lookup(WildflyManagerNode.class);

        if (!(node instanceof WildflyManagerNode)) {
            continue;
        }

        WildflyDeploymentManager dm = ((WildflyManagerNode) node).getDeploymentManager();
        InputOutput io = UISupport.getServerIO(dm.getUrl());
        if (io != null) {
            io.select();
        }

        InstanceProperties ip = dm.getInstanceProperties();
        WildflyOutputSupport outputSupport = WildflyOutputSupport.getInstance(ip, false);
        if (outputSupport == null) {
            outputSupport = WildflyOutputSupport.getInstance(ip, true);
            String serverDir = ip.getProperty(WildflyPluginProperties.PROPERTY_SERVER_DIR);
            String logFileName = serverDir + File.separator + "log" + File.separator + "server.log"; // NOI18N
            File logFile = new File(logFileName);
            if (logFile.exists()) {
                outputSupport.start(io, logFile);
            }
        }
    }
}
 
Example 15
Source File: NbIOProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void showIO(InputOutput io, Set<ShowOperation> operations) {
      if (operations.contains(ShowOperation.OPEN)
            && operations.contains(ShowOperation.MAKE_VISIBLE)
            && operations.size() == 2) {
        io.select();
    } else {
        IOSelect.select(io, showOperationsToIoSelect(operations));
    }
}
 
Example 16
Source File: BridgingInputOutputProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void showIO(InputOutput io,
        Set<ShowOperation> operations) {
    if (operations.contains(ShowOperation.OPEN)
            && operations.contains(ShowOperation.MAKE_VISIBLE)
            && operations.size() == 2) {
        io.select();
    } else {
        IOSelect.select(io, showOperationsToIoSelect(operations));
    }
}
 
Example 17
Source File: MainMemoryButtonListener.java    From BART with MIT License 4 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
        if(e.getActionCommand().equalsIgnoreCase("OK"))   {
            
            String schema = panel.getPanelMainMem().getXmlSchemaTextField().getText();
            String instance = panel.getPanelMainMem().getXmlInstanceTextField().getText();
            IDatabase tmpSource = dto.getEgtask().getSource();               
            IDatabase tmpTarget = dto.getEgtask().getTarget();

            InputOutput io = IOProvider.getDefault().getIO(dto.getPrimaryFile().getName(), false);
            OutputWindow.openOutputWindowStream(io.getOut(), io.getErr());
            try{
                io.select();
                ParserMainMemoryDatabase parserMainMemoryDatabase = new ParserMainMemoryDatabase();                   
                
                IDatabase newDB = parserMainMemoryDatabase.loadXMLScenario(schema, instance);
                
                if(dbmsT.equals("Source"))   {
                    dto.getEgtask().setSource(newDB);
                    dto.getEgtask().getAuthoritativeSources().clear();
                    dto.setXmlInstanceFilePathSourceDB(instance);
                    dto.setXmlSchemaFilePathSourceDB(schema);
                    dto.setMainMemoryGenerateSource(false);
                    dto.setPlainInstanceGenerateSourceDB(null);
                    dto.setEgtModified(true);
                    dto.getEgtask().setTarget(tmpTarget);
                    DbNodeNotifyer.fire();
                    DatabaseTableNotifier.fire();
                    EditDBNodeAction.closeDBTopComponent("Source");
                }
                
                if(dbmsT.equals("Target"))  {                      
                    dto.getEgtask().setTarget(newDB);
                    dto.setXmlInstanceFilePathTargetDB(instance);
                    dto.setXmlSchemaFilePathTargetDB(schema);
                    dto.setMainMemoryGenerateTager(false);
                    dto.setPlainInstanceGenerateTargetDB(null);
                    dto.setEgtModified(true);
                    dto.getEgtask().setSource(tmpSource);
                    DbNodeNotifyer.fire();
                    DatabaseTableNotifier.fire();
                    EditDBNodeAction.closeDBTopComponent("Target");
                } 
                
            }catch(Exception ex)   {
                dto.getEgtask().setSource(tmpSource);
                dto.getEgtask().setTarget(tmpTarget);
                DbNodeNotifyer.fire();
                DatabaseTableNotifier.fire();
                StringBuilder sb = new StringBuilder();
                sb.append("CHANGES CANCELED \n");
                sb.append("Error to \n parserMainMemoryDatabase.loadXMLScenario(schema, instance)\n");
                sb.append(""+ex);
                DialogDisplayer.getDefault().notify(
                    new NotifyDescriptor.Message(sb.toString(), 
                            NotifyDescriptor.ERROR_MESSAGE));
                return;
            }finally{
                OutputWindow.closeOutputWindowStream(io.getOut(), io.getErr());
            }
        }
    }
 
Example 18
Source File: T1_Close_Test.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void testStreamClose() {
// getIO(String, boolean newIO=false) reuses an IO
// that is not stream-open (i.e. streams never started
// or all closed.
System.out.printf("testStreamClose()\n");

InputOutput io1 = ioProvider.getIO("io1", null, ioContainer);

InputOutput io2;
InputOutput io3;

// until we open any streams reusing getIO should find it
io2 = ioProvider.getIO("io1", false, null , ioContainer);
assertTrue("reusing getIO() didn't find unopened IO", io2 == io1);

// after opening an io stream reusing getIO should create a new one.
io1.select();		// so we can check the output
io1.getOut().println("Hello to io1\r");
sleep(4);
io2 = ioProvider.getIO("io1", false, null, ioContainer);
if (defaultProvider) {
    // doesn't work as advertised
    // the following will appear in "io1".
    io2.getOut().println("Hello to io2\r");
} else {
    assertFalse("reusing getIO() found opened IO", io2 == io1);
    // This used to appear in a separate window, IOContainer.default(),
    // per BZ #182538, but it's fixed now.
    io2.select();
    io2.getOut().println("Hello to io2\r");
}
sleep(2);

// after closing io stream reusing getIO should find it
io1.getOut().close();
io3 = ioProvider.getIO("io1", false);
assertTrue("reusing getIO() didn't find stream closed IO", io3 == io1);

// at this point io1 and io3 point to the same io.

// but we can't write to it because we've closed it
io1.select();		// so we can check the output
io1.getOut().println("Should not appear\r");
sleep(3);

// until we reset it
try {
    io1.getOut().reset();
} catch (IOException ex) {
    Exceptions.printStackTrace(ex);
    fail("reset() failed");
}
io1.select();		// so we can check the output
io1.getOut().println("Hello to io1 after reset\r");
sleep(4);
   }
 
Example 19
Source File: LoadEGTask.java    From BART with MIT License 4 votes vote down vote up
@Override
public void run() {
    log.fine("START THREAD LOAD EGTASK");
    InputOutput io = IOProvider.getDefault().getIO(egtDO.getPrimaryFile().getName(), false);
    io.select();
    OutputWindow.openOutputWindowStream(io.getOut(), io.getErr());
    final ProgressHandle progr = ProgressHandleFactory.createHandle("Loading.... EGTask");
    progr.start();
    FileLock lock = null;
    try {
        log.fine("lock primary file");
        lock = egtDO.getPrimaryFile().lock();

        File taskFile = FileUtil.toFile(egtDO.getPrimaryFile());
        progr.progress("File loaded");
        log.fine("File loaded -> " + taskFile.getName());
        fileTask = taskFile.getAbsolutePath();

        conf = daoTaskConfiguration.loadConfiguration(fileTask);
        progr.progress("Configuration loaded");
        log.fine("Configuration loaded");

        if (conf.isRecreateDBOnStart()) {
            log.fine("Remove DB if exist");
            progr.progress("Remove DB if exist");
            removeExistingDB(fileTask);
        }

        task = daoTask.loadTask(fileTask);
        progr.progress("EGTask loaded");
        log.fine("EGTask loaded");

        if ((task.getTarget() != null) && (!(task.getTarget() instanceof EmptyDB))) {
            log.fine("Generate Dependency");
            for (Dependency dc : task.getDCs()) {
                dc.setVioGenQueries(vioGenQueriesGenerator.generateVioGenQueries(dc, task));
            }
        }

        progr.progress("Dependency generated");
        log.fine("Dependency generated");

        String dependencies = loadStringDependecyElement(fileTask);
        loadStringMainMemoryDatabase(fileTask);
        task.setAbsolutePath(fileTask);
        ((EGTaskDataObjectDataObject) egtDO).setEGTask(task);
        ((EGTaskDataObjectDataObject) egtDO).setDependencies((dependencies == null) ? null : dependencies.trim());

        System.out.println("CONFIGURATION: " + egtDO.getPrimaryFile().getName() + "  LOADED");
        esito = true;
        log.fine("FINISH LOAD EGTASK");
    } catch (Exception ex) {
        progr.progress("An error occurred. " + ex.getLocalizedMessage());
        log.log(Level.SEVERE, "An error occurred", ex);
        ErrorManager.getDefault().notify(ErrorManager.USER, ex);
        System.err.println("An error occurred " + ex.getLocalizedMessage());
        esito = false;
    } finally {
        if (lock != null) lock.releaseLock();
        OutputWindow.closeOutputWindowStream(io.getOut(), io.getErr());
        progr.finish();
        log.fine("Close OutputWindow and progressBar");
    }
}
 
Example 20
Source File: ShowChanges.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void run() {
    String name = NbBundle.getMessage(ShowChanges.class, "ShowChanges.title", build.getDisplayName());
    InputOutput io = IOProvider.getDefault().getIO(name, new Action[0]);
    io.select();
    OutputWriter out = io.getOut();
    OutputWriter err = io.getErr();
    Collection<? extends HudsonJobChangeItem> changes = build.getChanges();
    boolean first = true;
    for (HudsonJobChangeItem item : changes) {
        if (first) {
            first = false;
        } else {
            out.println();
        }
        out.println(item.getUser() + ": " + item.getMessage());
        for (HudsonJobChangeFile file : item.getFiles()) {
            // XXX hyperlink to diff viewer
            switch (file.getEditType()) {
            case edit:
                out.print('±');
                break;
            case add:
                out.print('+');
                break;
            case delete:
                out.print('-');
            }
            out.print(' ');
            OutputListener hyperlink = file.hyperlink();
            if (hyperlink != null) {
                try {
                    out.println(file.getName(), hyperlink);
                } catch (IOException x) {
                    LOG.log(Level.INFO, null, x);
                }
            } else {
                out.println(file.getName());
            }
        }
    }
    if (first) {
        out.println(NbBundle.getMessage(ShowChanges.class, "ShowChanges.no_changes"));
    }
    out.close();
    err.close();
}