List of usage examples for java.lang Thread setPriority
public final void setPriority(int newPriority)
From source file:org.coodex.concrete.attachments.server.UploadByFormResource.java
@Path("/{clientId}/{tokenId}") @POST/*w w w .j a va2s. c om*/ @Consumes({ MediaType.APPLICATION_FORM_URLENCODED, MediaType.MULTIPART_FORM_DATA }) @Produces(MediaType.APPLICATION_JSON) public void uploadByForm(@Suspended final AsyncResponse asyncResponse, @Context final HttpServletRequest request, @PathParam("clientId") final String clientId, @PathParam("tokenId") final String tokenId) { Thread t = new Thread(new Runnable() { @Override public void run() { try { ServletFileUpload uploadHandler = new ServletFileUpload(new DiskFileItemFactory()); List<FileItem> items = uploadHandler.parseRequest(request); List<AttachmentEntityInfo> result = new ArrayList<AttachmentEntityInfo>(); for (FileItem item : items) { if (!item.isFormField()) { if (!Common.isBlank(item.getName())) { AttachmentInfo attachmentInfo = new AttachmentInfo(); attachmentInfo.setName(item.getName()); attachmentInfo.setOwner(clientId); attachmentInfo.setSize(item.getSize()); attachmentInfo.setContentType(item.getContentType()); result.add(saveToRepo(clientId, tokenId, attachmentInfo, item.getInputStream())); } } } asyncResponse.resume(result); } catch (Throwable t) { asyncResponse.resume(t); } } }); t.setPriority(AttachmentServiceHelper.ATTACHMENT_PROFILE.getInt("upload.priority", 5)); t.start(); }
From source file:org.jajuk.base.Device.java
/** * Deep / full Refresh with GUI.//from ww w .ja v a 2s . c o m */ public void manualRefreshDeep() { final Thread t = new Thread("Device Deep Refresh Thread for : " + name) { @Override public void run() { manualRefresh(false, false, true, null); } }; t.setPriority(Thread.MIN_PRIORITY); t.start(); }
From source file:org.jajuk.base.Device.java
/** * Synchronizing asynchronously.// w ww.j av a2s .c o m * * @param bAsynchronous : * set asynchronous or synchronous mode */ public void synchronize(final boolean bAsynchronous) { // Check a source device is defined if (StringUtils.isBlank((String) getValue(Const.XML_DEVICE_SYNCHRO_SOURCE))) { Messages.showErrorMessage(171); return; } final Device device = this; if (!device.isMounted()) { try { device.mount(true); } catch (final Exception e) { Log.error(11, getName(), e); // mount failed Messages.showErrorMessage(11, getName()); return; } } if (bAsynchronous) { final Thread t = new Thread("Device Synchronize Thread") { @Override public void run() { synchronizeCommand(); } }; t.setPriority(Thread.MIN_PRIORITY); t.start(); } else { synchronizeCommand(); } }
From source file:ch.entwine.weblounge.contentrepository.impl.AbstractContentRepository.java
/** * Creates the previews for this resource in all languages and for all known * image styles. The implementation ensures that there is only one preview * renderer running per resource./* ww w . j ava 2s . c om*/ * * @param resource * the resource * @param languages * the languages to build the previews for */ protected void createPreviews(final Resource<?> resource, Language... languages) { ResourceURI uri = resource.getURI(); // Compile the full list of image styles if (imageStyleTracker == null) { logger.info("Skipping preview generation for {}: image styles are unavailable", uri); return; } final List<ImageStyle> previewStyles = new ArrayList<ImageStyle>(); // Add the global image styles that have the preview flag turned on for (ImageStyle s : imageStyleTracker.getImageStyles()) { if (s.isPreview()) { previewStyles.add(s); logger.debug("Preview images will be generated for {}", s); } else { logger.debug("Preview image generation will be skipped for {}", s); } } // Add the site's preview image styles as well as for (Module m : getSite().getModules()) { for (ImageStyle s : m.getImageStyles()) { if (s.isPreview()) { previewStyles.add(s); logger.debug("Preview images will be generated for {}", s); } else { logger.debug("Preview image generation will be skipped for {}", s); } } } // If no language has been specified, we create the preview for all // languages if (languages == null || languages.length == 0) { languages = uri.getSite().getLanguages(); } // Create the previews PreviewOperation previewOp = null; synchronized (currentPreviewOperations) { // is there an existing operation for this resource? If so, simply update // it and be done. previewOp = previews.get(uri); if (previewOp != null) { PreviewGeneratorWorker worker = previewOp.getWorker(); if (worker != null) { logger.info("Canceling current preview generation for {} in favor of more recent data", uri); worker.cancel(); } } // Otherwise, a new preview generator needs to be started. previewOp = new PreviewOperation(resource, Arrays.asList(languages), previewStyles, ImageStyleUtils.DEFAULT_PREVIEW_FORMAT); // Make sure nobody is working on the same resource at the moment if (currentPreviewOperations.contains(previewOp)) { logger.debug("Queing concurring creation of preview for {}", uri); previews.put(uri, previewOp); previewOperations.add(previewOp); return; } // If there is enough being worked on already, there is nothing we can do // right now, the work will be picked up later on if (currentPreviewOperations.size() >= maxPreviewOperations) { logger.debug("Queing creation of preview for {}", uri); previews.put(uri, previewOp); previewOperations.add(previewOp); logger.debug("Preview generation queue now contains {} resources", previews.size()); return; } // It seems like it is safe to start the preview generation currentPreviewOperations.add(previewOp); PreviewGeneratorWorker previewWorker = new PreviewGeneratorWorker(this, previewOp.getResource(), environment, previewOp.getLanguages(), previewOp.getStyles(), previewOp.getFormat()); previewOp.setWorker(previewWorker); Thread t = new Thread(previewWorker); t.setPriority(Thread.MIN_PRIORITY); t.setDaemon(true); logger.debug("Creating preview of {}", uri); t.start(); } }
From source file:org.jajuk.base.Device.java
/** * Refresh : scan the device to find tracks. * This method is only called from GUI. auto-refresh uses refreshCommand() directly. * /*from ww w. j a v a 2s .c o m*/ * @param bAsynchronous : * set asynchronous or synchronous mode * @param bAsk whether we ask for fast/deep scan * @param bAfterMove whether this is called after a device move * @param dirsToRefresh : only refresh specified dirs, or all of them if null */ public void refresh(final boolean bAsynchronous, final boolean bAsk, final boolean bAfterMove, final List<Directory> dirsToRefresh) { if (bAsynchronous) { final Thread t = new Thread("Device Refresh Thread for : " + name) { @Override public void run() { manualRefresh(bAsk, bAfterMove, false, dirsToRefresh); } }; t.setPriority(Thread.MIN_PRIORITY); t.start(); } else { manualRefresh(bAsk, bAfterMove, false, dirsToRefresh); } }
From source file:org.eclipse.scanning.event.SubscriberImpl.java
private void createDiseminateThread() { if (!isSynchronous()) return; // If asynch we do not run events in order and wait until they return. if (queue != null) return;//w ww .ja v a 2 s . c om queue = new LinkedBlockingQueue<>(); // Small, if they do work and things back-up, exceptions will occur. final Thread despachter = new Thread(new Runnable() { public void run() { while (isConnected()) { try { DiseminateEvent event = queue.take(); if (event == DiseminateEvent.STOP) return; diseminate(event); } catch (RuntimeException e) { e.printStackTrace(); logger.error("RuntimeException occured despatching event", e); continue; } catch (Exception e) { e.printStackTrace(); logger.error("Stopping event despatch thread ", e); return; } } System.out.println(Thread.currentThread().getName() + " disconnecting events."); } }, "Submitter despatch thread " + getSubmitQueueName()); despachter.setDaemon(true); despachter.setPriority(Thread.NORM_PRIORITY + 1); despachter.start(); }
From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.imagem.PanelDescricaoImagens.java
private void initComponentsEscalavel(ArrayList<FerramentaDescricaoModel> erros) { Ferramenta_Imagens.carregaTexto(TokenLang.LANG); JPanel regraFonteBtn = new JPanel(); regraFonteBtn.setLayout(new BorderLayout()); textAreaSourceCode = new G_TextAreaSourceCode(); textAreaSourceCode.setTipoHTML();//from w w w . j a va2s .c o m new OnChange(textAreaSourceCode, this); // parentFrame.setTitle("Associador de rtulos"); tableLinCod = new TabelaDescricao(this, erros); arTextPainelCorrecao = new ArTextPainelCorrecao(this); // scrollPaneCorrecaoLabel = new ConteudoCorrecaoLabel(); analiseSistematica = new JButton(); salvar = new JButton(); abrir = new JButton(); cancelar = new JButton(); strConteudoalt = new String(); // panelLegenda = new JPanel(); btnSalvar = new JMenuItem(GERAL.BTN_SALVAR); pnRegra = new JPanel(); lbRegras1 = new JLabel(); lbRegras2 = new JLabel(); pnSetaDescricao = new JPanel(); spTextoDescricao = new JScrollPane(); tArParticipRotulo = new TArParticipRotulo(this); conteudoDoAlt = new JTextArea(); pnListaErros = new JPanel(); scrollPanetabLinCod = new JScrollPane(); /** * Mostra pro usurio a imagem que est sem descrio */ imagemSemDesc = new XHTMLPanel(); pnBotoes = new JPanel(); salvar.setEnabled(false); salvaAlteracoes = TxtBuffer.getInstanciaSalvaAlteracoes(textAreaSourceCode.getTextPane(), salvar, new JMenuItem(), parentFrame); adicionar = new JButton(); aplicar = new JButton(); conteudoParticRotulo = new ArrayList<String>(); analiseSistematica.setEnabled(false); // setJMenuBar(this.criaMenuBar()); // ======== this ======== // setTitle("Associe explicitamente os r\u00f3tulos aos respectivos // controles:"); setBackground(CoresDefault.getCorPaineis()); Container contentPane = this;// ?? contentPane.setLayout(new GridLayout(2, 1)); // ======== pnRegra ======== { pnRegra.setBorder(criaBorda(Ferramenta_Imagens.TITULO_REGRA)); pnRegra.setLayout(new GridLayout(2, 1)); pnRegra.add(lbRegras1); lbRegras1.setText(Ferramenta_Imagens.REGRAP1); lbRegras2.setText(Ferramenta_Imagens.REGRAP2); lbRegras1.setHorizontalAlignment(SwingConstants.CENTER); lbRegras2.setHorizontalAlignment(SwingConstants.CENTER); pnRegra.add(lbRegras1); pnRegra.add(lbRegras2); pnRegra.setPreferredSize(new Dimension(700, 60)); } // G_URLIcon.setIcon(lbTemp, // "http://pitecos.blogs.sapo.pt/arquivo/pai%20natal%20o5.%20jpg.jpg"); JScrollPane sp = new JScrollPane(); sp.setViewportView(imagemSemDesc); sp.setPreferredSize(new Dimension(500, 300)); // ======== pnDescricao ======== // ---- Salvar ---- salvar.setText(Ferramenta_Imagens.BTN_SALVAR); salvar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { salvarActionPerformed(e); } }); salvar.setToolTipText(Ferramenta_Imagens.DICA_SALVAR); salvar.getAccessibleContext().setAccessibleDescription(Ferramenta_Imagens.DICA_SALVAR); salvar.getAccessibleContext().setAccessibleName(Ferramenta_Imagens.DICA_SALVAR); salvar.setBounds(10, 0, 150, 25); abrir.setText(Ferramenta_Imagens.BTN_ABRIR); abrir.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AbrirActionPerformed(e); } }); abrir.setToolTipText(Ferramenta_Imagens.DICA_ABRIR_HTML); abrir.getAccessibleContext().setAccessibleDescription(Ferramenta_Imagens.DICA_ABRIR_HTML); abrir.getAccessibleContext().setAccessibleName(Ferramenta_Imagens.DICA_ABRIR_HTML); abrir.setBounds(165, 0, 150, 25); cancelar.setText(Ferramenta_Imagens.TELA_ANTERIOR); cancelar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { CancelarActionPerformed(e); } }); cancelar.setToolTipText(Ferramenta_Imagens.DICA_TELA_ANTERIOR); cancelar.getAccessibleContext().setAccessibleDescription(Ferramenta_Imagens.DICA_TELA_ANTERIOR); cancelar.getAccessibleContext().setAccessibleName(Ferramenta_Imagens.TELA_ANTERIOR); cancelar.setBounds(320, 0, 150, 25); analiseSistematica.setText(GERAL.ANALISE_SISTEMATICA); analiseSistematica.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { buttonAction = e; Thread t = new Thread(new Runnable() { public void run() { PainelStatusBar.showProgTarReq(); parentFrame.setCursor(new Cursor(Cursor.WAIT_CURSOR)); analiseSistematicaActionPerformed(buttonAction); parentFrame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); PainelStatusBar.hideProgTarReq(); } }); t.setPriority(9); t.start(); } }); analiseSistematica.setToolTipText(GERAL.DICA_ANALISE_SISTEMATICA); analiseSistematica.getAccessibleContext().setAccessibleDescription(GERAL.DICA_ANALISE_SISTEMATICA); analiseSistematica.getAccessibleContext().setAccessibleName(GERAL.DICA_ANALISE_SISTEMATICA); analiseSistematica.setBounds(480, 0, 150, 25); // ======== pnParticRotulo ======== pnSetaDescricao.setBorder(criaBorda(Ferramenta_Imagens.TITULO_DIGITE_O_ALT)); GridBagConstraints cons = new GridBagConstraints(); GridBagLayout layout = new GridBagLayout(); cons.fill = GridBagConstraints.BOTH; cons.weighty = 1; cons.weightx = 0.80; pnSetaDescricao.setLayout(layout); cons.anchor = GridBagConstraints.SOUTHEAST; cons.insets = new Insets(0, 0, 0, 10); conteudoDoAlt.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent arg0) { } public void keyTyped(KeyEvent arg0) { } public void keyReleased(KeyEvent arg0) { if (conteudoDoAlt.getText().length() == 0) { System.out.println("conteudo vazio"); aplicar.setEnabled(false); } else if (tableLinCod.getSelectedRow() != -1) { System.out.println("com conteudo"); aplicar.setEnabled(true); } } }); // ======== spParticRotulo ======== { spTextoDescricao.setViewportView(conteudoDoAlt); } // lbRegras1.setText(Reparo_Imagens.REGRAP2); // lbRegras1.setHorizontalAlignment(SwingConstants.CENTER); // pnRegra.add(lbRegras1); pnSetaDescricao.add(spTextoDescricao, cons); cons.weightx = 0.20; pnSetaDescricao.setPreferredSize(new Dimension(400, 60)); // ======== pnListaErros ======== { pnListaErros.setBorder(criaBorda(Ferramenta_Imagens.LISTA_ERROS)); pnListaErros.setLayout(new BorderLayout()); // ======== scrollPanetabLinCod ======== { scrollPanetabLinCod.setViewportView(tableLinCod); } pnListaErros.add(scrollPanetabLinCod, BorderLayout.CENTER); } // ======== pnBotoes ======== { // pnBotoes.setBorder(criaBorda("")); pnBotoes.setLayout(null); // ---- adicionar ---- adicionar.setText(Ferramenta_Imagens.BTN_ADICIONAR); adicionar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { adicionarActionPerformed(e); } }); adicionar.setToolTipText(Ferramenta_Imagens.DICA_ADICIONAR); adicionar.getAccessibleContext().setAccessibleDescription(Ferramenta_Imagens.DICA_ADICIONAR); adicionar.getAccessibleContext().setAccessibleName(Ferramenta_Imagens.DICA_ADICIONAR); adicionar.setBounds(10, 5, 150, 25); // pnBotoes.add(adicionar); // ---- aplicarRotulo ---- aplicar.setEnabled(false); aplicar.setText(Ferramenta_Imagens.BTN_APLICAR); aplicar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { aplicarRotuloActionPerformed(e); } }); aplicar.setToolTipText(Ferramenta_Imagens.DICA_APLICAR); aplicar.getAccessibleContext().setAccessibleDescription(Ferramenta_Imagens.DICA_APLICAR); aplicar.getAccessibleContext().setAccessibleName(Ferramenta_Imagens.DICA_APLICAR); aplicar.setBounds(10, 5, 150, 25); pnBotoes.add(aplicar); } /* * Colocar os controles */ pnRegra.setBackground(CoresDefault.getCorPaineis()); regraFonteBtn.add(pnRegra, BorderLayout.NORTH); textAreaSourceCode.setBorder(criaBorda("")); textAreaSourceCode.setBackground(CoresDefault.getCorPaineis()); JSplitPane splitPane = null; Dimension minimumSize = new Dimension(0, 0); // JScrollPane ajudaScrollPane = new // JScrollPane(ajuda,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); sp.setMinimumSize(minimumSize); sp.setPreferredSize(new Dimension(150, 90)); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sp, textAreaSourceCode); splitPane.setOneTouchExpandable(true); // splitPane.set // splitPane.setDividerLocation(0.95); int w = parentFrame.getWidth(); int s = w / 4; splitPane.setDividerLocation(s); // regraFonteBtn.add(scrollPaneCorrecaoLabel, BorderLayout.CENTER); regraFonteBtn.add(splitPane, BorderLayout.CENTER); pnBotoes.setPreferredSize(new Dimension(600, 35)); pnBotoes.setBackground(CoresDefault.getCorPaineis()); // regraFonteBtn.add(pnBotoes, BorderLayout.SOUTH); regraFonteBtn.setBackground(CoresDefault.getCorPaineis()); contentPane.add(regraFonteBtn); JPanel textoErrosBtn = new JPanel(); textoErrosBtn.setLayout(new BorderLayout()); pnSetaDescricao.setBackground(CoresDefault.getCorPaineis()); pnSetaDescricao.add(pnBotoes, cons); textoErrosBtn.add(pnSetaDescricao, BorderLayout.NORTH); textoErrosBtn.add(pnListaErros, BorderLayout.CENTER); JPanel pnSalvarCancelar = new JPanel(); pnSalvarCancelar.setLayout(null); pnSalvarCancelar.setPreferredSize(new Dimension(600, 35)); pnSalvarCancelar.add(salvar); pnSalvarCancelar.add(abrir); pnSalvarCancelar.add(cancelar); if (!original) { reverter = new JButton("Reverter"); reverter.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setVisible(false); TxtBuffer.setContent(TxtBuffer.getContentOriginal()); parentFrame.showPainelFerramentaImgPArq(TxtBuffer.getContentOriginal(), enderecoPagina); setVisible(true); } }); //reverter.setActionCommand("Reverter"); reverter.setText(TradPainelRelatorio.REVERTER); reverter.setToolTipText(TradPainelRelatorio.DICA_REVERTER); reverter.getAccessibleContext().setAccessibleDescription(TradPainelRelatorio.DICA_REVERTER); reverter.getAccessibleContext().setAccessibleName(TradPainelRelatorio.DICA_REVERTER); if (EstadoSilvinha.conteudoEmPainelResumo) { reverter.setBounds(640, 0, 150, 25); } else { reverter.setBounds(480, 0, 150, 25); } pnSalvarCancelar.add(reverter); } if (EstadoSilvinha.conteudoEmPainelResumo) { pnSalvarCancelar.add(analiseSistematica); } pnSalvarCancelar.setBackground(CoresDefault.getCorPaineis()); textoErrosBtn.add(pnSalvarCancelar, BorderLayout.SOUTH); pnListaErros.setBackground(CoresDefault.getCorPaineis()); textoErrosBtn.add(pnListaErros, BorderLayout.CENTER); if (tableLinCod.getRowCount() == 0) tableLinCod.addLinha(0, 0, GERAL.DOC_SEM_ERROS); contentPane.setBackground(CoresDefault.getCorPaineis()); contentPane.add(textoErrosBtn); this.setVisible(true); }
From source file:io.reign.zk.ResilientZkClient.java
synchronized void spawnReconnectThread() { if (zooKeeper == null || zooKeeper.getState() == ZooKeeper.States.CLOSED) { // do connection in another thread so as to not block the ZK event thread Thread reconnectThread = new Thread() { @Override//from ww w . j av a2s. c om public void run() { connect(backoffStrategyFactory.get(), true); } }; reconnectThread .setName(this.getClass().getSimpleName() + ".zkConnectThread-" + reconnectThread.hashCode()); reconnectThread.setPriority(Thread.MIN_PRIORITY); reconnectThread.run(); } }
From source file:com.mibr.android.intelligentreminder.INeedToo.java
public void transmitNetwork(String thePhoneID) { if (thePhoneID.trim().toLowerCase().equals(this.getPhoneId().toLowerCase().trim())) { getLocationsTimer().schedule(new TimerTask() { public void run() { Thread notifyingThread = new Thread(null, mTaskTransmitNetwork, "TransmittingNetwork"); notifyingThread.setPriority(Thread.MIN_PRIORITY); notifyingThread.start(); }// w w w. j a v a 2s .c o m }, 1000 * 60 * 2); } }
From source file:ffx.ui.ModelingPanel.java
/** * Launch the active command on the active system in the specified * directory./* www . ja va2 s .co m*/ * * @param command The command to be excuted. * @param dir The directory to execute the command in. * @return a {@link ffx.ui.FFXExec} object. */ public FFXExec launch(String command, String dir) { logger.log(Level.INFO, "Command: {0}\nDirectory: {1}", new Object[] { command, dir }); synchronized (this) { // Check that the TINKER *.exe exists in TINKER/bin String path = MainPanel.ffxDir.getAbsolutePath(); File exe = new File(path + File.separator + activeCommand.toLowerCase()); if (!exe.exists()) { exe = new File(exe.getAbsolutePath() + ".exe"); if (!exe.exists()) { String message = "The " + activeCommand + " executable was not found in " + path + ". Please use the 'Set TINKER...' dialog to change the TINKER directory."; JOptionPane.showMessageDialog(null, message, "Could not launch " + activeCommand, JOptionPane.ERROR_MESSAGE); return null; } } // Check that the directory to execute the command in is valid File dirf = new File(dir); if (!dirf.exists()) { logger.log(Level.WARNING, "Directory doesn''t exist: {0}", dirf.getAbsolutePath()); return null; } // Check if we need a key file if (!commandFileTypes.contains(FileType.ANY)) { if (activeSystem == null) { return null; } activeFileType = FileType.XYZ; // Check that the TINKER command executes on this file type if (!commandFileTypes.contains(activeFileType)) { String message = activeCommand.toUpperCase() + " does not execute on " + activeFileType + " files."; JOptionPane.showMessageDialog(null, message, "Could not launch " + activeCommand, JOptionPane.ERROR_MESSAGE); return null; } // Check that a key file exists or prompt to create one. if (activeSystem.getKeyFile() == null) { mainPanel.createKeyFile(activeSystem); // Give up if the key file is null. if (activeSystem.getKeyFile() == null) { return null; } } } else { // Determine names to use for the output of Protein/Nucleic command = createCommandInput(); String structureName = commandTextArea.getText().trim(); if (!structureName.equalsIgnoreCase("")) { structureName = (structureName.split("\n"))[0]; if (structureName != null) { structureName = structureName.trim(); int dot = structureName.lastIndexOf("."); if (dot > 0) { structureName = structureName.substring(0, dot); } } } // If the above fails, just use the name of the executable // (protein or nulceic) if (structureName == null) { structureName = activeCommand.toLowerCase(); } File file = new File(dir + File.separator + structureName + ".xyz"); file = SystemFilter.version(file); activeSystem = new FFXSystem(file, null, Keyword.loadProperties(file)); File logFile = new File(file.getParent() + File.separator + structureName + ".log"); activeSystem.setLogFile(logFile); loadLogSettings(); activeFileType = FileType.ANY; // Need to have a parameter file chosen. mainPanel.openKey(activeSystem, true); if (activeSystem.getKeyFile() == null) { return null; } } // Decide on a Log file if (((String) logSettings.getSelectedItem()).startsWith("Create")) { File newLog = SystemFilter.version(activeSystem.getLogFile()); activeSystem.setLogFile(newLog); } String logName = activeSystem.getLogFile().getAbsolutePath(); // Determine the command string command = createCommandInput(); // If a new structure file will be created, determine what the name // will be. File newFile = null; if (commandActions.toUpperCase().contains("LOAD")) { File oldFile = activeSystem.getFile(); if (commandActions.toUpperCase().contains("LOADXYZ")) { String fileName = oldFile.getAbsolutePath(); int dot = fileName.lastIndexOf("."); if (dot > 0) { fileName = fileName.substring(0, dot) + ".xyz"; } oldFile = new File(fileName); } else if (commandActions.toUpperCase().contains("LOADINT")) { String fileName = oldFile.getAbsolutePath(); int dot = fileName.lastIndexOf("."); if (dot > 0) { fileName = fileName.substring(0, dot) + ".int"; } oldFile = new File(fileName); } else if (commandActions.toUpperCase().contains("LOADPDB")) { String fileName = oldFile.getAbsolutePath(); int dot = fileName.lastIndexOf("."); if (dot > 0) { fileName = fileName.substring(0, dot) + ".pdb"; } oldFile = new File(fileName); } newFile = SystemFilter.version(oldFile); } // Save any changes that have been made to the key file mainPanel.getKeywordPanel().saveChanges(); // Remove any TINKER *.END files removeEnd(); // Create the input file String commandInput = commandTextArea.getText(); if (commandInput != null && !commandInput.trim().equalsIgnoreCase("")) { File inputFile = new File(dir + File.separator + activeCommand.toLowerCase() + ".in"); inputFile.deleteOnExit(); try { FileWriter fw = new FileWriter(inputFile); fw.write(commandInput); fw.close(); } catch (Exception e) { logger.info(e.toString()); return null; } } // If the job progressively modifies coordinates, open a copy of it. boolean openOnto = false; if (commandActions.toUpperCase().contains("CONNECT")) { // If a version file is created, open it onto the structure used // to // display the job. if (newFile != null) { openOnto = true; } mainPanel.open(activeSystem.getFile(), activeCommand); try { while (mainPanel.isOpening()) { wait(10); } } catch (Exception e) { logger.info(e.toString()); return null; } activeSystem = mainPanel.getHierarchy().getActive(); } // Finally, create and execute the command in a new thread. FFXExec tinkerExec = new FFXExec(activeSystem, logName, command, dir, mainPanel, newFile, openOnto); Thread tinkerThread = new Thread(tinkerExec); tinkerThread.setPriority(Thread.NORM_PRIORITY); tinkerThread.setName(logName); // If the job progressively modifies coordinates, connect to it. if (commandActions.toUpperCase().contains("CONNECT")) { mainPanel.connectToTINKER(activeSystem, tinkerThread); } else { tinkerThread.start(); } // If some action should be taken when the job finishes, // add it to the Modeling Jobs Vector if (!commandActions.equalsIgnoreCase("NONE")) { executingCommands.add(tinkerThread); // mainPanel.getLogPanel().refreshStatus(); } return tinkerExec; } }