List of usage examples for java.awt Cursor getPredefinedCursor
public static Cursor getPredefinedCursor(int type)
From source file:de.juwimm.cms.Main.java
public void actionPerformed(ActionEvent e) { String action = e.getActionCommand(); this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); try {// ww w.ja va 2 s .c om if (action.equals(Constants.ACTION_EXIT)) { if (ActionHub.fireExitPerformed(new ExitEvent())) { comm.getDbHelper().shutdown(); System.exit(0); } } else if (action.equals(Constants.ACTION_LOGIN)) { this.setLayout(new BorderLayout()); Constants.CMS_CLIENT_VIEW = -1; setCenterPanel(PanInitView.getInstance()); if (panStatusbar == null) { panStatusbar = new PanStatusbar(); UIConstants.setStatusLine(panStatusbar); ActionHub.addActionListener(panStatusbar); } if (panRibbon == null) { panRibbon = new PanRibbon(comm); ActionHub.addActionListener(panRibbon); } this.getContentPane().add(panRibbon, BorderLayout.NORTH); ActionHub.fireActionPerformed( new ActionEvent(this, ActionEvent.ACTION_PERFORMED, Constants.ACTION_VIEW_EDITOR)); // this.getJMenuBar().setVisible(true); // this.getContentPane().add(panToolbar, BorderLayout.NORTH); this.getContentPane().add(panStatusbar, BorderLayout.SOUTH); this.getRootPane().setDoubleBuffered(true); this.getRootPane().validate(); this.getRootPane().repaint(); } else if (action.equals(Constants.ACTION_LOGOFF)) { if (ActionHub.fireExitPerformed(new ExitEvent())) { comm.setLoggedIn(false); Application.initializeContext(); panLogin = new PanLogin(); panRoot = null; panAdmin = null; panRibbon = null; this.getContentPane().removeAll(); //this.getJMenuBar().setVisible(false); comm.getDbHelper().autoEmptyCache(); PanContentView.getInstance().unloadAll(); setCenterPanel(panLogin); Constants.CMS_CLIENT_VIEW = Constants.CLIENT_VIEW_LOGIN; this.validate(); this.getContentPane().validate(); this.getContentPane().repaint(); this.repaint(); panLogin.init(); } } else if (action.equals(Constants.ACTION_VIEW_EDITOR)) { showToolPanel(false, e); panTool = PanTool.getInstance(); Constants.CMS_CLIENT_VIEW = Constants.CLIENT_VIEW_CONTENT; } else if (action.equals(Constants.ACTION_VIEW_EDITOR_WITH_SELECTION)) { showToolPanel(true, e); panTool = PanTool.getInstance(); Constants.CMS_CLIENT_VIEW = Constants.CLIENT_VIEW_CONTENT; } else if (action.equals(Constants.ACTION_VIEW_ADMIN) || action.equals(Constants.ACTION_VIEW_ROOT)) { Constants.CMS_CLIENT_VIEW = Constants.CLIENT_VIEW_ADMIN; showAdminPanel(); panStatusbar.setCountVisible(false); } else if (action.equals(Constants.ACTION_CHANGE_PASSWORD)) { showChangePasswordDialog(); } else if (action.equals(Constants.ACTION_SHOW_TASK)) { showTaskPanel(); panStatusbar.setCountVisible(false); Constants.CMS_CLIENT_VIEW = Constants.CLIENT_VIEW_TASK; } else if (action.equals(Constants.ACTION_SHOW_CONTENT)) { Constants.CMS_CLIENT_VIEW = Constants.CLIENT_VIEW_CONTENT; } } catch (Exception exe) { log.error("Error in actionPerformed", exe); } finally { this.setCursor(Cursor.getDefaultCursor()); } }
From source file:op.FrmMain.java
/** * This method is called from within the constructor to * initialize the form./*from ww w . j av a2 s . co m*/ * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the PrinterForm Editor. */ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { pnlMain = new JPanel(); pnlMainMessage = new JPanel(); btnTX = new JButton(); panel1 = new JPanel(); pnlIcons = new JPanel(); lblMainMsg = new JLabel(); btnExit = new JButton(); lblSubMsg = new JideLabel(); btnHelp = new JButton(); pbMsg = new JProgressBar(); btnReload = new JButton(); splitPaneLeft = new JideSplitPane(); pnlCard = new JPanel(); pnlWait = new JPanel(); lblWait = new JLabel(); pbTimeout = new JProgressBar(); panel2 = new JPanel(); btnResetSplitpane = new JButton(); statusBar = new StatusBar(); //======== this ======== setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setTitle("Offene-Pflege.de"); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { thisWindowClosing(e); } }); Container contentPane = getContentPane(); contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.X_AXIS)); //======== pnlMain ======== { pnlMain.setLayout(new FormLayout("0dlu, $lcgap, pref, $lcgap, left:default:grow, 2*($rgap)", "$rgap, pref, $rgap, default:grow, 3dlu, $nlgap, bottom:pref, $lgap, 0dlu")); //======== pnlMainMessage ======== { pnlMainMessage.setBackground(new Color(220, 223, 208)); pnlMainMessage.setBorder(new SoftBevelBorder(SoftBevelBorder.RAISED)); pnlMainMessage.setLayout(new FormLayout( "0dlu, $lcgap, 23dlu, $lcgap, default:grow, $lcgap, min, $lcgap, 0dlu", "0dlu, $lgap, 15dlu, $lgap, fill:11dlu, $lgap, fill:pref:grow, $lgap, pref, $lgap, 0dlu")); //---- btnTX ---- btnTX.setIcon(new ImageIcon(getClass().getResource("/artwork/32x32/ambulance2.png"))); btnTX.setBorder(null); btnTX.setBorderPainted(false); btnTX.setSelectedIcon(null); btnTX.setToolTipText("Verlegungsbericht drucken"); btnTX.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnTX.setPressedIcon( new ImageIcon(getClass().getResource("/artwork/32x32/ambulance2_pressed.png"))); btnTX.setContentAreaFilled(false); btnTX.addActionListener(e -> btnTXActionPerformed(e)); pnlMainMessage.add(btnTX, CC.xywh(3, 3, 1, 3)); //======== panel1 ======== { panel1.setOpaque(false); panel1.setLayout(new BoxLayout(panel1, BoxLayout.LINE_AXIS)); //======== pnlIcons ======== { pnlIcons.setOpaque(false); pnlIcons.setLayout(new BoxLayout(pnlIcons, BoxLayout.LINE_AXIS)); } panel1.add(pnlIcons); //---- lblMainMsg ---- lblMainMsg.setText("OPDE"); lblMainMsg.setFont(new Font("Arial Rounded MT Bold", Font.PLAIN, 22)); lblMainMsg.setForeground(new Color(105, 80, 69)); lblMainMsg.setHorizontalAlignment(SwingConstants.CENTER); lblMainMsg.setIcon(null); lblMainMsg.setHorizontalTextPosition(SwingConstants.LEADING); panel1.add(lblMainMsg); } pnlMainMessage.add(panel1, CC.xy(5, 3, CC.CENTER, CC.DEFAULT)); //---- btnExit ---- btnExit.setIcon(new ImageIcon(getClass().getResource("/artwork/32x32/lock.png"))); btnExit.setBorder(null); btnExit.setBorderPainted(false); btnExit.setOpaque(false); btnExit.setContentAreaFilled(false); btnExit.setToolTipText("Abmelden"); btnExit.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnExit.setPressedIcon(new ImageIcon(getClass().getResource("/artwork/32x32/lock_pressed.png"))); btnExit.addActionListener(e -> btnExitActionPerformed(e)); pnlMainMessage.add(btnExit, CC.xywh(7, 3, 1, 3)); //---- lblSubMsg ---- lblSubMsg.setText("OPDE"); lblSubMsg.setFont(new Font("Arial", Font.PLAIN, 14)); lblSubMsg.setForeground(new Color(105, 80, 69)); lblSubMsg.setHorizontalAlignment(SwingConstants.CENTER); lblSubMsg.setVerticalAlignment(SwingConstants.TOP); pnlMainMessage.add(lblSubMsg, CC.xywh(5, 5, 1, 3)); //---- btnHelp ---- btnHelp.setText(null); btnHelp.setIcon(new ImageIcon(getClass().getResource("/artwork/32x32/help.png"))); btnHelp.setBorderPainted(false); btnHelp.setContentAreaFilled(false); btnHelp.setPressedIcon(new ImageIcon(getClass().getResource("/artwork/32x32/help_pressed.png"))); btnHelp.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnHelp.addActionListener(e -> btnHelpActionPerformed(e)); pnlMainMessage.add(btnHelp, CC.xywh(3, 7, 1, 3)); //---- pbMsg ---- pbMsg.setValue(50); pbMsg.setFont(new Font("Arial Rounded MT Bold", Font.PLAIN, 12)); pbMsg.setForeground(new Color(105, 80, 69)); pnlMainMessage.add(pbMsg, CC.xy(5, 9, CC.FILL, CC.FILL)); //---- btnReload ---- btnReload.setIcon(new ImageIcon(getClass().getResource("/artwork/32x32/reload0000.png"))); btnReload.setBorder(null); btnReload.setBorderPainted(false); btnReload.setOpaque(false); btnReload.setContentAreaFilled(false); btnReload.setToolTipText("Ansicht aktualisieren"); btnReload.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnReload .setPressedIcon(new ImageIcon(getClass().getResource("/artwork/32x32/reload_pressed.png"))); btnReload.addActionListener(e -> btnReloadActionPerformed(e)); pnlMainMessage.add(btnReload, CC.xywh(7, 7, 1, 3)); } pnlMain.add(pnlMainMessage, CC.xywh(3, 2, 4, 1, CC.DEFAULT, CC.FILL)); //---- splitPaneLeft ---- splitPaneLeft.setOneTouchExpandable(true); splitPaneLeft.setProportionalLayout(true); splitPaneLeft.setShowGripper(true); splitPaneLeft.addPropertyChangeListener("dividerLocation", e -> splitPaneLeftPropertyChange(e)); pnlMain.add(splitPaneLeft, CC.xy(3, 4, CC.FILL, CC.FILL)); //======== pnlCard ======== { pnlCard.setLayout(new CardLayout()); //======== pnlWait ======== { pnlWait.setLayout(new BorderLayout()); //---- lblWait ---- lblWait.setText("text"); lblWait.setFont(new Font("Arial", Font.BOLD, 22)); lblWait.setHorizontalAlignment(SwingConstants.CENTER); pnlWait.add(lblWait, BorderLayout.CENTER); } pnlCard.add(pnlWait, "cardWait"); } pnlMain.add(pnlCard, CC.xy(5, 4, CC.FILL, CC.FILL)); pnlMain.add(pbTimeout, CC.xywh(3, 5, 4, 1, CC.FILL, CC.DEFAULT)); //======== panel2 ======== { panel2.setLayout(new BoxLayout(panel2, BoxLayout.X_AXIS)); //---- btnResetSplitpane ---- btnResetSplitpane.setText(null); btnResetSplitpane .setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/view_top_bottom.png"))); btnResetSplitpane.setAlignmentY(1.0F); btnResetSplitpane.addActionListener(e -> btnResetSplitpaneActionPerformed(e)); panel2.add(btnResetSplitpane); //---- statusBar ---- statusBar.setBackground(new Color(238, 238, 238)); statusBar.setAlignmentY(1.0F); panel2.add(statusBar); } pnlMain.add(panel2, CC.xywh(3, 7, 4, 1, CC.FILL, CC.BOTTOM)); } contentPane.add(pnlMain); setSize(945, 695); setLocationRelativeTo(getOwner()); }
From source file:org.eclipse.birt.chart.device.swing.SwingEventHandler.java
private void setCursor(JComponent composite, org.eclipse.birt.chart.model.attribute.Cursor cursor, Cursor defaultCursor) {// w ww . j a va2 s . c o m if (cursor == null || cursor.getType() == CursorType.AUTO) { composite.setCursor(defaultCursor); return; } else if (cursor.getType() == CursorType.CUSTOM) { // Find the first valid image as custom cursor. EList<org.eclipse.birt.chart.model.attribute.Image> uris = cursor.getImage(); for (org.eclipse.birt.chart.model.attribute.Image uri : uris) { try { Image image = null; if (uri instanceof EmbeddedImage) { try { byte[] data = Base64.decodeBase64(((EmbeddedImage) uri).getData().getBytes()); image = new ImageIcon(data).getImage(); } catch (Exception ilex) { logger.log(ilex); } } else { URI u = new URI(uri.getURL()); image = composite.getToolkit().createImage(SecurityUtil.toURL(u)); } if (image != null) { composite.setCursor(composite.getToolkit().createCustomCursor(image, new Point(0, 0), ""));//$NON-NLS-1$ return; } } catch (URISyntaxException e) { // Do not process exception here. } catch (MalformedURLException e) { // Do not process exception here. } } // No valid image is found, set default cursor. composite.setCursor(defaultCursor); return; } composite.setCursor(Cursor.getPredefinedCursor(SwingHelper.CURSOR_MAP.get(cursor.getType()).intValue())); }
From source file:org.executequery.gui.editor.QueryEditorTextPane.java
private void fireTextUpdateStarting() { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); uninstallListeners(); }
From source file:JavaXWin.java
public void mouseMoved(MouseEvent e) { if (!m_dragging) { if (e.getX() < CORNER) { setCursor(Cursor.getPredefinedCursor(Cursor.SW_RESIZE_CURSOR)); } else if (e.getX() > getWidth() - CORNER) { setCursor(Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR)); } else {/* w w w . j a v a 2 s.co m*/ setCursor(Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR)); } } }
From source file:op.care.med.inventory.PnlInventory.java
private CollapsiblePane createCP4(final MedInventory inventory) { /***//from w w w . ja v a2 s . c om * _ ____ ____ _ _ _____ _ __ * ___ _ __ ___ __ _| |_ ___ / ___| _ \| || | / /_ _|_ ____ _____ _ __ | |_ ___ _ __ _ \ \ * / __| '__/ _ \/ _` | __/ _ \ | | |_) | || |_| | | || '_ \ \ / / _ \ '_ \| __/ _ \| '__| | | | | * | (__| | | __/ (_| | || __/ |___| __/|__ _| | | || | | \ V / __/ | | | || (_) | | | |_| | | * \___|_| \___|\__,_|\__\___|\____|_| |_| | ||___|_| |_|\_/ \___|_| |_|\__\___/|_| \__, | | * \_\ |___/_/ */ final String key = inventory.getID() + ".xinventory"; synchronized (cpMap) { if (!cpMap.containsKey(key)) { cpMap.put(key, new CollapsiblePane()); try { cpMap.get(key).setCollapsed(true); } catch (PropertyVetoException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } cpMap.get(key).setName("inventory"); // final CollapsiblePane cpInventory = cpMap.get(key); BigDecimal sumInventory = BigDecimal.ZERO; try { EntityManager em = OPDE.createEM(); sumInventory = MedInventoryTools.getSum(em, inventory); em.close(); } catch (Exception e) { OPDE.fatal(e); } String title = "<html><table border=\"0\">" + "<tr>" + "<td width=\"520\" align=\"left\"><font size=+1>" + inventory.getText() + "</font></td>" + "<td width=\"200\" align=\"right\"><font size=+1>" + NumberFormat.getNumberInstance().format(sumInventory) + " " + DosageFormTools.getPackageText(MedInventoryTools.getForm(inventory)) + "</font></td>" + "</tr>" + "</table>" + "</html>"; DefaultCPTitle cptitle = new DefaultCPTitle(title, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { cpMap.get(key).setCollapsed(!cpMap.get(key).isCollapsed()); } catch (PropertyVetoException pve) { // BAH! } } }); cpMap.get(key).setTitleLabelComponent(cptitle.getMain()); cpMap.get(key).setSlidingDirection(SwingConstants.SOUTH); cptitle.getButton().setIcon(inventory.isClosed() ? SYSConst.icon22stopSign : null); if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.MANAGER, "nursingrecords.inventory")) { /*** * ____ _ ___ _ * / ___| | ___ ___ ___|_ _|_ ____ _____ _ __ | |_ ___ _ __ _ _ * | | | |/ _ \/ __|/ _ \| || '_ \ \ / / _ \ '_ \| __/ _ \| '__| | | | * | |___| | (_) \__ \ __/| || | | \ V / __/ | | | || (_) | | | |_| | * \____|_|\___/|___/\___|___|_| |_|\_/ \___|_| |_|\__\___/|_| \__, | * |___/ */ final JButton btnCloseInventory = new JButton(SYSConst.icon22playerStop); btnCloseInventory.setPressedIcon(SYSConst.icon22playerStopPressed); btnCloseInventory.setAlignmentX(Component.RIGHT_ALIGNMENT); btnCloseInventory.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnCloseInventory.setContentAreaFilled(false); btnCloseInventory.setBorder(null); btnCloseInventory.setToolTipText(SYSTools.xx("nursingrecords.inventory.btncloseinventory.tooltip")); btnCloseInventory.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgYesNo( SYSTools.xx("nursingrecords.inventory.question.close1") + "<br/><b>" + inventory.getText() + "</b>" + "<br/>" + SYSTools.xx("nursingrecords.inventory.question.close2"), SYSConst.icon48playerStop, new Closure() { @Override public void execute(Object answer) { if (answer.equals(JOptionPane.YES_OPTION)) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); MedInventory myInventory = em.merge(inventory); em.lock(myInventory, LockModeType.OPTIMISTIC); em.lock(myInventory.getResident(), LockModeType.OPTIMISTIC); // close all stocks for (MedStock stock : MedStockTools.getAll(myInventory)) { if (!stock.isClosed()) { MedStock mystock = em.merge(stock); em.lock(mystock, LockModeType.OPTIMISTIC); mystock.setNextStock(null); MedStockTools.close(em, mystock, SYSTools.xx( "nursingrecords.inventory.stock.msg.inventory_closed"), MedStockTransactionTools.STATE_EDIT_INVENTORY_CLOSED); } } // close inventory myInventory.setTo(new Date()); em.getTransaction().commit(); createCP4(myInventory); buildPanel(); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager() .addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } } }); } }); btnCloseInventory.setEnabled(!inventory.isClosed()); cptitle.getRight().add(btnCloseInventory); } if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.DELETE, "nursingrecords.inventory")) { /*** * ____ _ ___ _ * | _ \ ___| |_ _|_ ____ _____ _ __ | |_ ___ _ __ _ _ * | | | |/ _ \ || || '_ \ \ / / _ \ '_ \| __/ _ \| '__| | | | * | |_| | __/ || || | | \ V / __/ | | | || (_) | | | |_| | * |____/ \___|_|___|_| |_|\_/ \___|_| |_|\__\___/|_| \__, | * |___/ */ final JButton btnDelInventory = new JButton(SYSConst.icon22delete); btnDelInventory.setPressedIcon(SYSConst.icon22deletePressed); btnDelInventory.setAlignmentX(Component.RIGHT_ALIGNMENT); btnDelInventory.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnDelInventory.setContentAreaFilled(false); btnDelInventory.setBorder(null); btnDelInventory.setToolTipText(SYSTools.xx("nursingrecords.inventory.btndelinventory.tooltip")); btnDelInventory.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgYesNo( SYSTools.xx("nursingrecords.inventory.question.delete1") + "<br/><b>" + inventory.getText() + "</b>" + "<br/>" + SYSTools.xx("nursingrecords.inventory.question.delete2"), SYSConst.icon48delete, new Closure() { @Override public void execute(Object answer) { if (answer.equals(JOptionPane.YES_OPTION)) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); MedInventory myInventory = em.merge(inventory); em.lock(myInventory, LockModeType.OPTIMISTIC); em.lock(myInventory.getResident(), LockModeType.OPTIMISTIC); em.remove(myInventory); em.getTransaction().commit(); // lstInventories.remove(inventory); buildPanel(); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager() .addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } } }); } }); cptitle.getRight().add(btnDelInventory); } final JToggleButton tbClosedStock = GUITools.getNiceToggleButton(null); tbClosedStock.setToolTipText(SYSTools.xx("nursingrecords.inventory.showclosedstocks")); if (!inventory.isClosed()) { tbClosedStock.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { cpMap.get(key).setContentPane(createContentPanel4(inventory, tbClosedStock.isSelected())); } }); } tbClosedStock.setSelected(inventory.isClosed()); tbClosedStock.setEnabled(!inventory.isClosed()); mapKey2ClosedToggleButton.put(key, tbClosedStock); cptitle.getRight().add(tbClosedStock); CollapsiblePaneAdapter adapter = new CollapsiblePaneAdapter() { @Override public void paneExpanded(CollapsiblePaneEvent collapsiblePaneEvent) { cpMap.get(key).setContentPane(createContentPanel4(inventory, tbClosedStock.isSelected())); } }; synchronized (cpListener) { if (cpListener.containsKey(key)) { cpMap.get(key).removeCollapsiblePaneListener(cpListener.get(key)); } cpListener.put(key, adapter); cpMap.get(key).addCollapsiblePaneListener(adapter); } if (!cpMap.get(key).isCollapsed()) { cpMap.get(key).setContentPane(createContentPanel4(inventory, tbClosedStock.isSelected())); } cpMap.get(key).setHorizontalAlignment(SwingConstants.LEADING); cpMap.get(key).setOpaque(false); cpMap.get(key).setBackground(getColor(SYSConst.medium2, lstInventories.indexOf(inventory) % 2 != 0)); return cpMap.get(key); } }
From source file:org.executequery.gui.editor.QueryEditorTextPane.java
private void fireTextUpdateFinished() { updateLineBorder(); reinstallListeners(); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); }
From source file:com.qspin.qtaste.ui.TestCaseTree.java
public void drop(DropTargetDropEvent dtde) { //try/* ww w. j a v a 2s .c o m*/ { try { TCTreeNode tcTreeNode = (TCTreeNode) dtde.getTransferable().getTransferData(localObjectFlavor); Point dropPoint = dtde.getLocation(); // int index = locationToIndex (dropPoint); TreePath path = getPathForLocation(dropPoint.x, dropPoint.y); Object targetNode = path.getLastPathComponent(); if (targetNode instanceof TCTreeNode) { // rename the dragged dir into the new target one TCTreeNode tcTargetNode = (TCTreeNode) targetNode; FileNode fn = (FileNode) tcTargetNode.getUserObject(); if (fn.isTestcaseDir()) { dtde.rejectDrop(); return; } FileNode draggedFileNode = (FileNode) tcTreeNode.getUserObject(); draggedFileNode.getFile() .renameTo(new File(fn.getFile() + "/" + draggedFileNode.getFile().getName())); // update target tree testCasePane.parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); TCTreeNode parentTreeNode = (TCTreeNode) tcTargetNode.getParent(); if (parentTreeNode != null) { parentTreeNode.removeAllChildren(); FileNode parentFileNode = (FileNode) parentTreeNode.getUserObject(); addTreeToDir(parentFileNode.getFile(), parentTreeNode); ((DefaultTreeModel) getModel()).reload(parentTreeNode); } else { tcTargetNode.removeAllChildren(); FileNode targetFileNode = (FileNode) tcTargetNode.getUserObject(); addTreeToDir(targetFileNode.getFile(), tcTargetNode); ((DefaultTreeModel) getModel()).reload(tcTargetNode); } // update source tree parentTreeNode = (TCTreeNode) tcTreeNode.getParent(); if (parentTreeNode != null) { parentTreeNode.removeAllChildren(); FileNode parentFileNode = (FileNode) parentTreeNode.getUserObject(); addTreeToDir(parentFileNode.getFile(), parentTreeNode); ((DefaultTreeModel) getModel()).reload(parentTreeNode); } else { tcTreeNode.removeAllChildren(); FileNode targetFileNode = (FileNode) tcTreeNode.getUserObject(); addTreeToDir(targetFileNode.getFile(), tcTreeNode); ((DefaultTreeModel) getModel()).reload(tcTreeNode); } testCasePane.parent.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); dtde.getDropTargetContext().dropComplete(true); } else { dtde.rejectDrop(); } } catch (UnsupportedFlavorException ex) { logger.error(ex.getMessage()); } catch (IOException ex) { logger.error(ex.getMessage()); } } }
From source file:org.sleuthkit.autopsy.keywordsearch.ExtractedContentViewer.java
private void previousPage() { if (currentSource.hasPreviousPage()) { currentSource.previousPage();// ww w. java2 s .c o m //set new text panel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); panel.refreshCurrentMarkup(); panel.setCursor(null); //update display panel.updateCurrentPageDisplay(currentSource.getCurrentPage()); //scroll to current selection ExtractedContentViewer.this.scrollToCurrentHit(); //update controls if needed if (!currentSource.hasPreviousPage()) { panel.enablePrevPageControl(false); } if (currentSource.hasNextPage()) { panel.enableNextPageControl(true); } updateSearchControls(); } }
From source file:rita.widget.SourceCode.java
private void createCompileButton() { ImageIcon imgIcon = new ImageIcon(getClass().getResource("/images/sourcecode/bytecode.png")); this.compileButton = new JButton(imgIcon); this.compileButton.setToolTipText(Language.get("compileButton.tooltip")); final File basePathRobots = new File(Settings.getRobotsPath()); compileButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { // guardar el codigo fuente File sourcePath = saveSourceCode(); // COMPILA EN EL DIRECTORIO POR DEFAULT + LA RUTA DEL PACKAGE Collection<File> inFiles = createClassFiles(sourcePath); if (inFiles != null) { /* transformar el codigo fuente, que no tiene errores, para que los println aparezcan en una ventana. * La transformacin no deberia generar errores. */// www. j av a2s . c o m writeSourceFile(sourcePath, AgregadorDeConsola.getInstance().transformar(readSourceFile(sourcePath))); // volver a compilar, ahora con el codigo transformado inFiles = createClassFiles(sourcePath); if (inFiles != null) { createJarFile(inFiles); System.out.println("INSTALLPATH=" + Settings.getInstallPath()); System.out.println("SE ENVIA ROBOT:" + HelperEditor.currentRobotPackage + "." + HelperEditor.currentRobotName); // si quiere seleccionar enemigos if (Settings.getProperty("level.default").equals(Language.get("level.four"))) { try { DialogSelectEnemies.getInstance(); } catch (NoEnemiesException e2) { new MessageDialog(Language.get("robot.noEnemies"), MessageType.ERROR); } return; } else { callBatalla(null, null); } } else { System.out.println("Error en codigo transformado por AgregadorDeConsola"); } } } catch (Exception e1) { e1.printStackTrace(); } } /** Recibe un archivo conteniendo codigo fuente java, y crea el .class correspondiente * @param sourcePath El archivo .java * @return Un archivo conteniendo el path al .class generado, o null si no fue posible compilar porque hubo errores en el codigo fuente. */ private Collection<File> createClassFiles(File sourcePath) throws Exception, IOException { Collection<File> f = CompileString.compile(sourcePath, basePathRobots); if (CompileString.hasError()) { int cantErrores = 0; for (Diagnostic<?> diag : CompileString.diagnostics) { if (!diag.getKind().equals(Kind.WARNING)) { int line = (int) diag.getLineNumber(); int col = (int) diag.getColumnNumber(); if (line > 0 && col > 0) { highlightCode(line, col); cantErrores++; } } } if (cantErrores > 0) { new MessageDialog(Language.get("compile.error"), MessageType.ERROR); } return null; } else { return f; } } /* crea un jar con todas las clases del robot. el nombre del jar es el nombre del robot */ private void createJarFile(Collection<File> inFiles) throws FileNotFoundException, IOException { File jarFile = new File(basePathRobots, HelperEditor.currentRobotName + ".jar"); if (jarFile.exists()) { jarFile.delete(); } System.out.println("Path del JAR ==" + jarFile); jarFile.createNewFile(); FileOutputStream fos = new FileOutputStream(jarFile); BufferedOutputStream bo = new BufferedOutputStream(fos); Manifest manifest = new Manifest(); manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0"); JarOutputStream jarOutput = new JarOutputStream(fos, manifest); int basePathLength = basePathRobots.getAbsolutePath().length() + 1; // +1 para incluir al "/" final byte[] buf = new byte[1024]; int anz; try { // para todas las clases... for (File inFile : inFiles) { BufferedInputStream bi = new BufferedInputStream(new FileInputStream(inFile)); try { String relative = inFile.getAbsolutePath().substring(basePathLength); // copia y agrega el archivo .class al jar JarEntry je2 = new JarEntry(relative); jarOutput.putNextEntry(je2); while ((anz = bi.read(buf)) != -1) { jarOutput.write(buf, 0, anz); } jarOutput.closeEntry(); } finally { try { bi.close(); } catch (IOException ignored) { } } } } finally { try { jarOutput.close(); } catch (IOException ignored) { } try { fos.close(); } catch (IOException ignored) { } try { bo.close(); } catch (IOException ignored) { } } } }); compileButton.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { e.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } @Override public void mouseExited(MouseEvent e) { e.getComponent().setCursor(Cursor.getDefaultCursor()); } }); compileButton.setBounds(MIN_WIDTH, 0, MAX_WIDTH - MIN_WIDTH, BUTTON_HEIGHT); compileButton.setFont(smallButtonFont); compileButton.setAlignmentX(LEFT_ALIGNMENT); compileButton.setText(Language.get("compileButton.title")); }