Example usage for java.awt Cursor getPredefinedCursor

List of usage examples for java.awt Cursor getPredefinedCursor

Introduction

In this page you can find the example usage for java.awt Cursor getPredefinedCursor.

Prototype

public static Cursor getPredefinedCursor(int type) 

Source Link

Document

Returns a cursor object with the specified predefined type.

Usage

From source file:org.openmicroscopy.shoola.agents.metadata.editor.EditorUI.java

/**
 * Removes the links, tags attachments.//  w w w .  j  av  a 2s .  c o m
 * 
 * @param level One of the constants defined by this class.
 */
private void removeLinks(int level, Collection l) {
    saved = true;
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    toolBar.setDataToSave(false);
    Iterator<AnnotationData> i = l.iterator();
    AnnotationData o;
    List<Object> toRemove = new ArrayList<Object>();
    List<Object> links;
    while (i.hasNext()) {
        o = i.next();
        links = model.getLinks(level, o);
        if (links != null) {
            toRemove.addAll(links);
        }
    }
    DataToSave object = new DataToSave(new ArrayList<AnnotationData>(), toRemove);
    model.fireAnnotationSaving(object, null, true);
}

From source file:org.sleuthkit.autopsy.casemodule.Case.java

/**
 * Creates a new case (create the XML config file and database)
 *
 * @param caseDir    The directory to store case data in. Will be created if
 *                   it doesn't already exist. If it exists, it should have
 *                   all of the needed sub dirs that createCaseDirectory()
 *                   will create.//  ww w .j  av a  2  s  .  c  o m
 * @param caseName   the name of case
 * @param caseNumber the case number
 * @param examiner   the examiner for this case
 * @param caseType   the type of case, single-user or multi-user
 */
public static void create(String caseDir, String caseName, String caseNumber, String examiner,
        CaseType caseType) throws CaseActionException {
    logger.log(Level.INFO, "Creating new case.\ncaseDir: {0}\ncaseName: {1}",
            new Object[] { caseDir, caseName }); //NON-NLS

    // create case directory if it doesn't already exist.
    if (new File(caseDir).exists() == false) {
        Case.createCaseDirectory(caseDir, caseType);
    }

    String configFilePath = caseDir + File.separator + caseName + CASE_DOT_EXTENSION;

    XMLCaseManagement xmlcm = new XMLCaseManagement();

    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HHmmss");
    Date date = new Date();
    String santizedCaseName = sanitizeCaseName(caseName);
    String indexName = santizedCaseName + "_" + dateFormat.format(date);
    String dbName = null;

    // figure out the database name and index name for text extraction
    if (caseType == CaseType.SINGLE_USER_CASE) {
        dbName = caseDir + File.separator + "autopsy.db"; //NON-NLS
    } else if (caseType == CaseType.MULTI_USER_CASE) {
        dbName = indexName;
    }

    xmlcm.create(caseDir, caseName, examiner, caseNumber, caseType, dbName, indexName); // create a new XML config file
    xmlcm.writeFile();

    SleuthkitCase db = null;
    try {
        if (caseType == CaseType.SINGLE_USER_CASE) {
            db = SleuthkitCase.newCase(dbName);
        } else if (caseType == CaseType.MULTI_USER_CASE) {
            db = SleuthkitCase.newCase(dbName, UserPreferences.getDatabaseConnectionInfo(), caseDir);
        }
    } catch (TskCoreException ex) {
        logger.log(Level.SEVERE,
                "Error creating a case: " + caseName + " in dir " + caseDir + " " + ex.getMessage(), ex); //NON-NLS
        SwingUtilities.invokeLater(() -> {
            WindowManager.getDefault().getMainWindow()
                    .setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
        });
        throw new CaseActionException(ex.getMessage(), ex); //NON-NLS
    } catch (UserPreferencesException ex) {
        logger.log(Level.SEVERE, "Error accessing case database connection info", ex); //NON-NLS
        throw new CaseActionException(NbBundle.getMessage(Case.class, "Case.databaseConnectionInfo.error.msg"),
                ex);
    }

    /**
     * Two-stage initialization to avoid leaking reference to "this" in
     * constructor.
     */
    Case newCase = new Case(caseName, caseNumber, examiner, configFilePath, xmlcm, db, caseType);
    changeCase(newCase);
}

From source file:org.revager.gui.findings_list.FindingsListFrame.java

private void createAttPanel() {
    GridLayout grid = new GridLayout(4, 1);
    grid.setVgap(8);//from  w w w.j  av  a2 s  .  c  o  m

    JPanel attendeeButtons = new JPanel(grid);

    addResiAtt = GUITools.newImageButton();
    addResiAtt.setIcon(Data.getInstance().getIcon("addResiAtt_25x25_0.png"));
    addResiAtt.setRolloverIcon(Data.getInstance().getIcon("addResiAtt_25x25.png"));
    addResiAtt.setToolTipText(translate("Add Attendee from the Attendee Pool"));
    addResiAtt.addActionListener(ActionRegistry.getInstance().get(AddResiAttToProtAction.class.getName()));
    attendeeButtons.add(addResiAtt);

    JButton addAttendee = GUITools.newImageButton();
    addAttendee.setIcon(Data.getInstance().getIcon("addAttendee_25x25_0.png"));
    addAttendee.setRolloverIcon(Data.getInstance().getIcon("addAttendee_25x25.png"));
    addAttendee.setToolTipText(translate("Add Attendee"));
    addAttendee.addActionListener(ActionRegistry.getInstance().get(AddAttToProtAction.class.getName()));
    attendeeButtons.add(addAttendee);

    removeAttendee = GUITools.newImageButton();
    removeAttendee.setIcon(Data.getInstance().getIcon("removeAttendee_25x25_0.png"));
    removeAttendee.setRolloverIcon(Data.getInstance().getIcon("removeAttendee_25x25.png"));
    removeAttendee.setToolTipText(translate("Remove Attendee"));
    removeAttendee.addActionListener(ActionRegistry.getInstance().get(RemAttFromProtAction.class.getName()));
    attendeeButtons.add(removeAttendee);

    editAttendee = GUITools.newImageButton();
    editAttendee.setIcon(Data.getInstance().getIcon("editAttendee_25x25_0.png"));
    editAttendee.setRolloverIcon(Data.getInstance().getIcon("editAttendee_25x25.png"));
    editAttendee.setToolTipText(translate("Edit Attendee"));
    editAttendee.addActionListener(ActionRegistry.getInstance().get(EditAttFromProtAction.class.getName()));
    attendeeButtons.add(editAttendee);

    editAttendee.setEnabled(false);
    removeAttendee.setEnabled(false);

    presentAttTable.setRowHeight(55);
    presentAttTable.getColumnModel().getColumn(0).setMaxWidth(55);
    presentAttTable.setShowHorizontalLines(false);
    presentAttTable.setShowVerticalLines(true);
    presentAttTable.setShowGrid(true);
    presentAttTable.addMouseListener(new MouseListener() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
                ActionRegistry.getInstance().get(EditAttFromProtAction.class.getName()).actionPerformed(null);
            }
        }

        @Override
        public void mouseEntered(MouseEvent e) {
        }

        @Override
        public void mouseExited(MouseEvent e) {
        }

        @Override
        public void mousePressed(MouseEvent e) {
        }

        @Override
        public void mouseReleased(MouseEvent e) {
        }
    });

    TableCellRenderer renderer = (table, value, isSelected, hasFocus, row, column) -> {
        JLabel label = new JLabel((String) value);
        label.setOpaque(true);
        label.setBorder(new EmptyBorder(5, 5, 5, 5));

        label.setFont(UI.VERY_LARGE_FONT);

        if (isSelected) {
            label.setBackground(presentAttTable.getSelectionBackground());
        } else {
            if (row % 2 == 0) {
                label.setBackground(UI.TABLE_ALT_COLOR);
            } else {
                label.setBackground(presentAttTable.getBackground());
            }
        }
        return label;
    };

    for (int i = 1; i <= 4; i++) {
        presentAttTable.getColumnModel().getColumn(i).setCellRenderer(renderer);
    }

    TableColumn col = presentAttTable.getColumnModel().getColumn(0);
    col.setCellRenderer((table, value, isSelected, hasFocus, row, column) -> {
        JPanel localPnl = new JPanel();
        localPnl.add(new JLabel(Data.getInstance().getIcon("attendee_40x40.png")));
        if (isSelected) {
            localPnl.setBackground(presentAttTable.getSelectionBackground());
        } else {
            if (row % 2 == 0) {
                localPnl.setBackground(UI.TABLE_ALT_COLOR);
            } else {
                localPnl.setBackground(presentAttTable.getBackground());
            }
        }
        return localPnl;
    });
    presentAttTable.addMouseListener(new MouseListener() {
        @Override
        public void mouseClicked(MouseEvent e) {
            updateAttButtons();
        }

        @Override
        public void mouseEntered(MouseEvent e) {
        }

        @Override
        public void mouseExited(MouseEvent e) {
        }

        @Override
        public void mousePressed(MouseEvent e) {
        }

        @Override
        public void mouseReleased(MouseEvent e) {
        }
    });

    scrllP = GUITools.setIntoScrollPane(presentAttTable);
    scrllP.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    scrllP.setToolTipText(translate("Add Attendee to Meeting"));
    scrllP.addMouseListener(new MouseListener() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (isAddResiAttPossible()) {
                ActionRegistry.getInstance().get(AddResiAttToProtAction.class.getName()).actionPerformed(null);
            } else {
                ActionRegistry.getInstance().get(AddAttToProtAction.class.getName()).actionPerformed(null);
            }
        }

        @Override
        public void mouseEntered(MouseEvent e) {
        }

        @Override
        public void mouseExited(MouseEvent e) {
        }

        @Override
        public void mousePressed(MouseEvent e) {
        }

        @Override
        public void mouseReleased(MouseEvent e) {
        }
    });

    JLabel labelAttendees = new JLabel(translate("Attendees of the current meeting:"));
    labelAttendees.setFont(UI.HUGE_FONT_BOLD);

    GUITools.addComponent(attPanel, gbl, labelAttendees, 0, 0, 2, 1, 1.0, 0.0, 20, 20, 0, 20,
            GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST);
    GUITools.addComponent(attPanel, gbl, scrllP, 0, 1, 1, 1, 1.0, 1.0, 20, 20, 0, 20, GridBagConstraints.BOTH,
            GridBagConstraints.NORTHWEST);
    GUITools.addComponent(attPanel, gbl, attendeeButtons, 1, 1, 1, 1, 0, 0, 20, 0, 20, 20,
            GridBagConstraints.NONE, GridBagConstraints.NORTHWEST);
}

From source file:org.openmicroscopy.shoola.agents.metadata.view.MetadataViewerComponent.java

/** 
 * Implemented as specified by the {@link MetadataViewer} interface.
 * @see MetadataViewer#onDataSave(List)//from   w ww  .  j  ava2s .  c om
 */
public void onDataSave(List<DataObject> data) {
    if (data == null)
        return;
    if (model.getState() == DISCARDED)
        return;
    DataObject dataObject = null;
    if (data.size() == 1)
        dataObject = data.get(0);
    if (dataObject != null && model.isSameObject(dataObject)) {
        setRootObject(model.getRefObject(), model.getUserID(), model.getSecurityContext());
        model.setState(READY);
        firePropertyChange(ON_DATA_SAVE_PROPERTY, null, dataObject);
    } else {
        if (model.isSameSelection(data))
            model.setRelatedNodes(data);
        else
            model.setState(READY);
        firePropertyChange(ON_DATA_SAVE_PROPERTY, null, data);
    }
    view.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    fireStateChange();
}

From source file:AltiConsole.AltiConsoleMainScreen.java

public boolean ErasingFlight() {
    this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    if (Serial.getConnected() == false) {
        boolean ret = false;
        ret = ConnectToAlti();//from  w  w  w .  ja  v a  2s .c  o m
        if (!ret) {
            System.out.println("Data retrieval timed out\n");
            this.setCursor(Cursor.getDefaultCursor());
            return false;
        }
    }
    Serial.writeData("e;\n");
    this.setCursor(Cursor.getDefaultCursor());
    return true;
}

From source file:ca.phon.app.project.ProjectWindow.java

private MultiActionButton createNewCorpusButton() {
    MultiActionButton retVal = new MultiActionButton();

    ImageIcon folderNewIcn = IconManager.getInstance().getIcon("places/folder", IconSize.SMALL);
    ImageIcon newIcnL = IconManager.getInstance().getIcon("actions/list-add", IconSize.MEDIUM);
    ImageIcon removeIcnL = IconManager.getInstance().getIcon("actions/list-remove", IconSize.MEDIUM);
    ImageIcon renameIcnL = IconManager.getInstance().getIcon("actions/edit-rename", IconSize.MEDIUM);

    String s1 = "Corpus";

    retVal.getTopLabel().setText(WorkspaceTextStyler.toHeaderText(s1));
    retVal.getTopLabel().setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
    retVal.getTopLabel().setFont(FontPreferences.getTitleFont());
    retVal.getTopLabel().setIcon(folderNewIcn);
    retVal.setOpaque(false);/* w ww .j ava2s. com*/

    PhonUIAction newAct = new PhonUIAction(this, "onSwapNewAndCreateCorpus", retVal);
    newAct.putValue(Action.LARGE_ICON_KEY, newIcnL);
    newAct.putValue(Action.SMALL_ICON, folderNewIcn);
    newAct.putValue(Action.NAME, "New corpus");
    newAct.putValue(Action.SHORT_DESCRIPTION, "Create a new corpus folder");

    DeleteCorpusAction deleteCurrentAct = new DeleteCorpusAction(this);
    deleteCurrentAct.putValue(Action.LARGE_ICON_KEY, removeIcnL);

    PhonUIAction renameCurrentAct = new PhonUIAction(this, "onRenameCorpus");
    renameCurrentAct.putValue(Action.LARGE_ICON_KEY, renameIcnL);
    renameCurrentAct.putValue(Action.NAME, "Rename corpus");
    renameCurrentAct.putValue(Action.SHORT_DESCRIPTION, "Rename selected corpus");

    retVal.setDisplayDefaultAction(true);
    retVal.addAction(deleteCurrentAct);
    retVal.addAction(renameCurrentAct);

    retVal.setDefaultAction(newAct);

    retVal.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

    return retVal;
}

From source file:base.BasePlayer.BedCanvas.java

void drawSidebar() {

    buf.setColor(Draw.sidecolor.darker());
    buf.fillRect(0, 0, Main.sidebarWidth - 4, this.getHeight());
    //   buf.setColor(Draw.softColor);
    //   buf.fillRect(0, 0, Main.sidebarWidth, this.getHeight());
    buf.setColor(Color.black);//from w w w.  j ava 2  s .c  o m

    if (bedTrack.size() > 0) {
        //   buf.setStroke(Draw.doubleStroke);
        overlapping = false;
        for (int i = 0; i < bedTrack.size(); i++) {
            if (!buf.getColor().equals(Color.black)) {
                buf.setColor(Color.black);
            }
            if (i == 0) {
                trackstart = Main.defaultFontSize;
                trackheight = (int) (trackDivider.get(i) * this.getHeight());
            } else {

                trackstart = Main.defaultFontSize + (int) (trackDivider.get(i - 1) * this.getHeight());
                trackheight = (int) (trackDivider.get(i) * this.getHeight())
                        - (int) (trackDivider.get(i - 1) * this.getHeight());
            }

            if (bedTrack.get(i).file != null) {

                buf.drawString(bedTrack.get(i).file.getName(), 10, trackstart);
            } else {

                buf.drawString(FilenameUtils.getName(bedTrack.get(i).url.getFile()), 10, trackstart);
            }

            if (trackheight > Main.defaultFontSize + Main.defaultFontSize
                    + (int) (Main.defaultFontSize * 1.4)) {

                if ((int) bedTrack.get(i).playbox.y != trackstart + Main.defaultFontSize) {

                    bedTrack.get(i).playbox.setBounds(10, trackstart + Main.defaultFontSize,
                            (int) (Main.defaultFontSize * 1.4), (int) (Main.defaultFontSize * 1.4));
                    bedTrack.get(i).playTriangle.reset();
                    bedTrack.get(i).playTriangle.addPoint(
                            bedTrack.get(i).playbox.x + (Main.defaultFontSize / 5),
                            bedTrack.get(i).playbox.y + (Main.defaultFontSize / 5));
                    bedTrack.get(i).playTriangle.addPoint(
                            bedTrack.get(i).playbox.x + (Main.defaultFontSize / 5), bedTrack.get(i).playbox.y
                                    + (bedTrack.get(i).playbox.width - (Main.defaultFontSize / 5)));
                    bedTrack.get(i).playTriangle.addPoint(
                            bedTrack.get(i).playbox.x
                                    + (bedTrack.get(i).playbox.width - (Main.defaultFontSize / 5)),
                            bedTrack.get(i).playbox.y + bedTrack.get(i).playbox.height / 2);
                    bedTrack.get(i).graphBox.setBounds(
                            bedTrack.get(i).playbox.x + (int) (Main.defaultFontSize * 1.4)
                                    + Main.defaultFontSize,
                            trackstart + Main.defaultFontSize, (int) (Main.defaultFontSize * 1.4),
                            (int) (Main.defaultFontSize * 1.4));
                    if (bedTrack.get(i).settingsButton == null) {
                        bedTrack.get(i).settingsButton = new Rectangle();
                    }
                    bedTrack.get(i).settingsButton.setBounds(
                            Main.sidebarWidth - (int) (this.remoBox.width * (1.8)) - 4,
                            trackstart - Main.defaultFontSize, (int) (this.remoBox.width * (1.5)) + 2,
                            (int) (this.remoBox.height * (1.5)));

                }
                if (bedTrack.get(i).settingsButton == null) {
                    bedTrack.get(i).settingsButton = new Rectangle();
                }
                if (bedTrack.get(i).settingsButton.y == 0
                        || bedTrack.get(i).settingsButton.x != Main.sidebarWidth
                                - (int) (this.remoBox.width * (1.8))
                        || bedTrack.get(i).settingsButton.width != (int) (this.remoBox.width * (1.5)) + 2) {
                    bedTrack.get(i).settingsButton.setBounds(
                            Main.sidebarWidth - (int) (this.remoBox.width * (1.8)),
                            trackstart - Main.defaultFontSize - 4, (int) (this.remoBox.width * (1.5)) + 2,
                            (int) (this.remoBox.height * (1.5)));

                }
                if (Main.varsamples > 0 || FileRead.caller) {
                    if (bedTrack.get(i).getCurrent() != null
                            || (!bedTrack.get(i).small || bedTrack.get(i).getZoomlevel() != null)) {
                        buf.setColor(Color.white);
                        buf.fillRoundRect(bedTrack.get(i).playbox.getBounds().x - 1,
                                bedTrack.get(i).playbox.getBounds().y - 1,
                                bedTrack.get(i).playbox.getBounds().width,
                                bedTrack.get(i).playbox.getBounds().height, 2, 2);
                        buf.setColor(Color.gray);
                        buf.fillRoundRect(bedTrack.get(i).playbox.getBounds().x + 1,
                                bedTrack.get(i).playbox.getBounds().y + 1,
                                bedTrack.get(i).playbox.getBounds().width,
                                bedTrack.get(i).playbox.getBounds().height, 2, 2);
                        if (sideMouseRect.intersects(bedTrack.get(i).playbox)) {
                            overlapping = true;
                            if (getCursor().getType() != Cursor.HAND_CURSOR) {
                                selectedPlay = i;
                                setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                            }
                            buf.setColor(Color.white);
                            //   buf.drawRect(bedTrack.get(i).playbox.getBounds().x-1,bedTrack.get(i).playbox.getBounds().y-1,bedTrack.get(i).playbox.getBounds().width+1, bedTrack.get(i).playbox.getBounds().height+1);
                            buf.fillRoundRect(bedTrack.get(i).playbox.getBounds().x,
                                    bedTrack.get(i).playbox.getBounds().y,
                                    bedTrack.get(i).playbox.getBounds().width,
                                    bedTrack.get(i).playbox.getBounds().height, 2, 2);

                        } else {
                            buf.setColor(Draw.sidecolor);
                            buf.fillRoundRect(bedTrack.get(i).playbox.getBounds().x,
                                    bedTrack.get(i).playbox.getBounds().y,
                                    bedTrack.get(i).playbox.getBounds().width,
                                    bedTrack.get(i).playbox.getBounds().height, 2, 2);
                        }
                        if (bedTrack.get(i).intersect) {
                            buf.setColor(Draw.greenColor);
                            buf.fillRect(bedTrack.get(i).playTriangle.getBounds().x,
                                    bedTrack.get(i).playTriangle.getBounds().y,
                                    bedTrack.get(i).playTriangle.getBounds().width,
                                    bedTrack.get(i).playTriangle.getBounds().height);
                        } else {
                            buf.setColor(Draw.redColor);
                            buf.fillPolygon(bedTrack.get(i).playTriangle);
                        }
                    }
                }

                if (bedTrack.get(i).hasvalues) {

                    if (bedTrack.get(i).getCurrent() != null || !bedTrack.get(i).small) {
                        buf.setColor(Color.lightGray);
                        buf.fillRect(bedTrack.get(i).graphBox.getBounds().x,
                                bedTrack.get(i).graphBox.getBounds().y,
                                bedTrack.get(i).graphBox.getBounds().width,
                                bedTrack.get(i).graphBox.getBounds().height);
                        buf.setColor(Color.white);
                        buf.fillRoundRect(bedTrack.get(i).graphBox.getBounds().x - 1,
                                bedTrack.get(i).graphBox.getBounds().y - 1,
                                bedTrack.get(i).graphBox.getBounds().width,
                                bedTrack.get(i).graphBox.getBounds().height, 2, 2);
                        buf.setColor(Color.gray);
                        buf.fillRoundRect(bedTrack.get(i).graphBox.getBounds().x + 1,
                                bedTrack.get(i).graphBox.getBounds().y + 1,
                                bedTrack.get(i).graphBox.getBounds().width,
                                bedTrack.get(i).graphBox.getBounds().height, 2, 2);
                        if (sideMouseRect.intersects(bedTrack.get(i).graphBox)) {
                            overlapping = true;
                            if (getCursor().getType() != Cursor.HAND_CURSOR) {
                                selectedPlay = i;
                                setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                            }
                            buf.setColor(Color.white);
                            //   buf.drawRect(bedTrack.get(i).graphBox.getBounds().x-1,bedTrack.get(i).graphBox.getBounds().y-1,bedTrack.get(i).graphBox.getBounds().width+1, bedTrack.get(i).graphBox.getBounds().height+1);
                            buf.fillRoundRect(bedTrack.get(i).graphBox.getBounds().x,
                                    bedTrack.get(i).graphBox.getBounds().y,
                                    bedTrack.get(i).graphBox.getBounds().width,
                                    bedTrack.get(i).graphBox.getBounds().height, 2, 2);

                        } else {
                            buf.setColor(Draw.sidecolor);
                            buf.fillRoundRect(bedTrack.get(i).graphBox.getBounds().x,
                                    bedTrack.get(i).graphBox.getBounds().y,
                                    bedTrack.get(i).graphBox.getBounds().width,
                                    bedTrack.get(i).graphBox.getBounds().height, 2, 2);
                        }
                        if (bedTrack.get(i).graph) {
                            buf.setColor(Draw.greenColor);
                            buf.drawLine(bedTrack.get(i).graphBox.getBounds().x,
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + bedTrack.get(i).graphBox.getBounds().height,
                                    bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width / 4,
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + bedTrack.get(i).graphBox.getBounds().height / 2);
                            buf.drawLine(
                                    bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width / 4,
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + bedTrack.get(i).graphBox.getBounds().height / 2,
                                    bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width / 2,
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + (int) (bedTrack.get(i).graphBox.getBounds().height * 0.66));
                            buf.drawLine(
                                    bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width / 2,
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + (int) (bedTrack.get(i).graphBox.getBounds().height * 0.66),
                                    (int) (bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width * 0.66),
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + bedTrack.get(i).graphBox.getBounds().height / 4);
                            buf.drawLine(
                                    (int) (bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width * 0.66),
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + bedTrack.get(i).graphBox.getBounds().height / 4,
                                    bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width,
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + bedTrack.get(i).graphBox.getBounds().height / 2);

                        } else {
                            buf.setColor(Draw.redColor);
                            buf.drawLine(bedTrack.get(i).graphBox.getBounds().x,
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + bedTrack.get(i).graphBox.getBounds().height,
                                    bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width / 4,
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + bedTrack.get(i).graphBox.getBounds().height / 2);
                            buf.drawLine(
                                    bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width / 4,
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + bedTrack.get(i).graphBox.getBounds().height / 2,
                                    bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width / 2,
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + (int) (bedTrack.get(i).graphBox.getBounds().height * 0.66));
                            buf.drawLine(
                                    bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width / 2,
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + (int) (bedTrack.get(i).graphBox.getBounds().height * 0.66),
                                    (int) (bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width * 0.66),
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + bedTrack.get(i).graphBox.getBounds().height / 4);
                            buf.drawLine(
                                    (int) (bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width * 0.66),
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + bedTrack.get(i).graphBox.getBounds().height / 4,
                                    bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width,
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + bedTrack.get(i).graphBox.getBounds().height / 2);

                        }
                        /*if(sideMouseRect.intersects(bedTrack.get(i).graphBox)) {
                                   
                           overlapping = true;
                           selectedPlay = i;
                           if(getCursor().getType() != Cursor.HAND_CURSOR) {
                                      
                              setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                           }   
                           buf.setColor(Color.white);
                           buf.drawRect(bedTrack.get(i).graphBox.getBounds().x-1,bedTrack.get(i).graphBox.getBounds().y-1,bedTrack.get(i).graphBox.getBounds().width+1, bedTrack.get(i).graphBox.getBounds().height+1);
                                   
                        }*/
                    }
                }
            }
            if (trackheight > bedTrack.get(i).settingsButton.height) {
                /*if(this.sideMouseRect.intersects(bedTrack.get(i).settingsButton)) {                        
                   buf.setColor(Color.white);
                }
                else {         
                           
                }*/
                buf.setColor(Draw.sidecolor.darker());
                buf.fillRect(bedTrack.get(i).settingsButton.x, bedTrack.get(i).settingsButton.y,
                        bedTrack.get(i).settingsButton.width, bedTrack.get(i).settingsButton.height);
                buf.drawImage(Main.settingsIcon.getImage(),
                        Main.sidebarWidth - (int) (this.remoBox.width * (1.8)) - 4,
                        trackstart - Main.defaultFontSize, (int) (this.remoBox.width * (1.5)),
                        (int) (this.remoBox.height * (1.5)), this);
            }
        }

        if (!overlapping && !resizer) {

            if (getCursor().getType() != Cursor.DEFAULT_CURSOR) {

                selectedPlay = -1;
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        }
        if (sidebar) {
            buf.setColor(Color.black);

            if (sidebar && sideMouseRect.intersects(this.remoBox)) {
                //   buf.setStroke(Draw.doubleStroke);
                removeTrack = hoverIndex;
                buf.setColor(Color.white);
                buf.fillRect(this.remoBox.x - 2, this.remoBox.y - 1, this.remoBox.width + 2,
                        this.remoBox.height + 2);
            } else {
                removeTrack = -1;
                if (this.remoBox.getBounds().x != Main.sidebarWidth - (Main.defaultFontSize + 10) - 4
                        || this.remoBox.getBounds().y != (int) (trackDivider.get(hoverIndex) * this.getHeight())
                                - (Main.defaultFontSize + 6)) {
                    this.remoBox.setBounds(Main.sidebarWidth - (Main.defaultFontSize + 10) - 4,
                            (int) (trackDivider.get(hoverIndex) * this.getHeight())
                                    - (Main.defaultFontSize + 6),
                            Main.defaultFontSize + 3, Main.defaultFontSize + 3);
                }
                /*   if(this.remoBox.getBounds().y != (int)(trackDivider.get(hoverIndex)*this.getHeight())-11|| this.remoBox.getBounds().x != Main.sidebarWidth-11) {
                      this.remoBox.setBounds(Main.sidebarWidth-11, (int)(trackDivider.get(hoverIndex)*this.getHeight())-11, 8, 8);
                   }*/
            }

            buf.setColor(Color.black);
            buf.drawRect(this.remoBox.x, this.remoBox.y, this.remoBox.width, this.remoBox.height);
            buf.drawLine(this.remoBox.x, this.remoBox.y, this.remoBox.x + this.remoBox.width,
                    this.remoBox.y + (int) this.remoBox.getHeight());
            buf.drawLine(this.remoBox.x, this.remoBox.y + (int) this.remoBox.getHeight(),
                    this.remoBox.x + this.remoBox.width, this.remoBox.y);

        }
        buf.setStroke(Draw.doubleStroke);
        buf.setColor(Color.gray);
        buf.drawLine(Main.sidebarWidth - 5, 0, Main.sidebarWidth - 5, this.getHeight());
        buf.drawLine(1, 0, 1, this.getHeight());
        buf.setColor(Color.lightGray);
        buf.drawLine(3, 0, 3, this.getHeight());
        buf.drawLine(Main.sidebarWidth - 7, 0, Main.sidebarWidth - 7, this.getHeight());
        buf.setStroke(Draw.basicStroke);
    }

}

From source file:org.omegat.gui.main.ProjectUICommands.java

public static void projectReload() {
    UIThreadsUtil.mustBeSwingThread();//from w ww  .  j av  a  2  s. co  m

    if (!Core.getProject().isProjectLoaded()) {
        return;
    }

    // commit the current entry first
    Core.getEditor().commitAndLeave();

    final ProjectProperties props = Core.getProject().getProjectProperties();

    new SwingWorker<Object, Void>() {
        int previousCurEntryNum = Core.getEditor().getCurrentEntryNumber();

        protected Object doInBackground() throws Exception {
            IMainWindow mainWindow = Core.getMainWindow();
            Cursor hourglassCursor = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
            Cursor oldCursor = mainWindow.getCursor();
            mainWindow.setCursor(hourglassCursor);

            Core.executeExclusively(true, () -> {
                Core.getProject().saveProject(true);
                ProjectFactory.closeProject();

                ProjectFactory.loadProject(props, true);
            });
            mainWindow.setCursor(oldCursor);
            return null;
        }

        protected void done() {
            try {
                get();
                SwingUtilities.invokeLater(() -> {
                    // activate entry later - after project will be loaded
                    Core.getEditor().gotoEntry(previousCurEntryNum);
                    Core.getEditor().requestFocus();
                });
            } catch (Exception ex) {
                processSwingWorkerException(ex, "PP_ERROR_UNABLE_TO_READ_PROJECT_FILE");
            }
        }
    }.execute();
}

From source file:biz.wolschon.finance.jgnucash.JGnucash.java

/**
 * Show the file->save as... -dialog.
 *//*from  ww w .  j  a  v  a  2  s  .c  o  m*/
private void saveFileAs() {
    int state = getJFileChooser().showSaveDialog(this);
    if (state == JFileChooser.APPROVE_OPTION) {
        File f = getJFileChooser().getSelectedFile();
        try {
            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

            getWritableModel().writeFile(f);
            saveFile();
            setTitle(f.getName());
        } catch (FileNotFoundException e) {
            LOGGER.error("cannot save file '" + f.getAbsolutePath() + "' (file not found)", e);
            JOptionPane.showMessageDialog(this, "Error",
                    "cannot save file '" + f.getAbsolutePath() + "' (file not found)",
                    JOptionPane.ERROR_MESSAGE);
        } catch (IOException e) {
            LOGGER.error("cannot save file '" + f.getAbsolutePath() + "' (io-problem)", e);
            JOptionPane.showMessageDialog(this, "Error",
                    "cannot save file '" + f.getAbsolutePath() + "' (io-problem)", JOptionPane.ERROR_MESSAGE);
        } catch (JAXBException e) {
            LOGGER.error("cannot save file '" + f.getAbsolutePath() + "' (gnucash-format-problem)", e);
            JOptionPane.showMessageDialog(this, "Error",
                    "cannot save file '" + f.getAbsolutePath() + "' (gnucash-format-problem)",
                    JOptionPane.ERROR_MESSAGE);
        } finally {
            setCursor(Cursor.getDefaultCursor());
        }
    }
}

From source file:AltiConsole.AltiConsoleMainScreen.java

public boolean RetrievingFlight() {
    this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    listData = null;//  w  ww  .j av a  2s.  c om

    listData = new DefaultListModel();

    if (Serial.getConnected() == false) {
        boolean ret = false;
        ret = ConnectToAlti();
        if (!ret) {
            System.out.println("Data retrieval timed out1\n");
            JOptionPane.showMessageDialog(null, trans.get("AltiConsoleMainScreen.dataTimeOut"),
                    trans.get("AltiConsoleMainScreen.ConnectionError"), JOptionPane.ERROR_MESSAGE);
            this.setCursor(Cursor.getDefaultCursor());
            return false;
        }
    }
    // check the connection
    //Serial.DataReady = false;
    Serial.setDataReady(false);
    Serial.writeData("h;\n");
    long startTime; // = System.currentTimeMillis();
    Serial.lastReceived = System.currentTimeMillis();
    while (!Serial.getDataReady()) {
        long currentTime = System.currentTimeMillis();
        startTime = Serial.lastReceived;
        if ((currentTime - startTime) > 130000) {
            // This is some sort of data retrieval timeout
            System.out.println("Data retrieval timed out2 flight\n");
            JOptionPane.showMessageDialog(null, trans.get("AltiConsoleMainScreen.dataTimeOut"),
                    trans.get("AltiConsoleMainScreen.ConnectionError"), JOptionPane.ERROR_MESSAGE);
            this.setCursor(Cursor.getDefaultCursor());
            return false;
        }
    }

    Serial.initFlightData(UserPref.getAppUnits());

    // get the flight data
    //Serial.DataReady = false;
    Serial.setDataReady(false);
    Serial.writeData("a;\n");

    Serial.lastReceived = System.currentTimeMillis();
    while (!Serial.getDataReady()) {
        long currentTime = System.currentTimeMillis();
        startTime = Serial.lastReceived;
        if ((currentTime - startTime) > 130000) {
            // This is some sort of data retrieval timeout
            System.out.println("Data retrieval timed out3\n");
            JOptionPane.showMessageDialog(null, trans.get("AltiConsoleMainScreen.dataTimeOut"),
                    trans.get("AltiConsoleMainScreen.ConnectionError"), JOptionPane.ERROR_MESSAGE);
            this.setCursor(Cursor.getDefaultCursor());
            return false;
        }
    }
    System.out.println("done retrieving flight\n");
    List<String> AllFlightNames2;

    AllFlightNames2 = Serial.MyFlight.getAllFlightNames2();

    for (String z : AllFlightNames2) {

        listData.addElement(z);
    }

    flightList.setModel(listData);
    flightList.setAutoCreateRowSorter(true);
    flightList.toggleSortOrder();
    flightList.setSortOrder(SortOrder.ASCENDING);

    flightList.clearSelection();

    flightList.setSelectedIndex(0);
    if (Serial.MyFlight.FlightExist("Flight 1")) {
        plot.setDataset(0, Serial.MyFlight.GetFlightData("Flight 1"));
    }
    this.setCursor(Cursor.getDefaultCursor());
    return true;

}