Example usage for java.awt Frame ICONIFIED

List of usage examples for java.awt Frame ICONIFIED

Introduction

In this page you can find the example usage for java.awt Frame ICONIFIED.

Prototype

int ICONIFIED

To view the source code for java.awt Frame ICONIFIED.

Click Source Link

Document

This state bit indicates that frame is iconified.

Usage

From source file:com.tag.FramePreferences.java

@SuppressWarnings("serial")
public FramePreferences(final JInternalFrame frame, String pathName) {
    setFrame(new Frame() {

        @Override/* ww  w  .ja v  a  2 s .  c  om*/
        public synchronized int getExtendedState() {
            if (frame.isMaximum()) {
                return Frame.MAXIMIZED_BOTH;
            } else if (frame.isIcon()) {
                return Frame.ICONIFIED;
            } else {
                return Frame.NORMAL;
            }
        }

        @Override
        public synchronized void setExtendedState(int state) {
            try {
                switch (state) {
                case Frame.MAXIMIZED_HORIZ:
                case Frame.MAXIMIZED_VERT:
                case Frame.MAXIMIZED_BOTH:
                    frame.setMaximum(true);
                    break;
                case Frame.ICONIFIED:
                    frame.setIcon(true);
                    break;
                case Frame.NORMAL:
                    frame.setIcon(false);
                    frame.setMaximum(false);
                    break;
                }
            } catch (PropertyVetoException e) {
                e.printStackTrace();
            }
        }

        @Override
        public synchronized void addWindowStateListener(final WindowStateListener l) {
            final Frame source = this;
            frame.addInternalFrameListener(new InternalFrameAdapter() {

                @Override
                public void internalFrameIconified(InternalFrameEvent e) {
                    l.windowStateChanged(new WindowEvent(source, WindowEvent.WINDOW_ICONIFIED));
                }

                @Override
                public void internalFrameDeiconified(InternalFrameEvent e) {
                    l.windowStateChanged(new WindowEvent(source, WindowEvent.WINDOW_DEICONIFIED));
                }

            });
        }

        @Override
        public synchronized void removeWindowStateListener(WindowStateListener l) {
            super.removeWindowStateListener(l);
        }

        @Override
        public GraphicsConfiguration getGraphicsConfiguration() {
            return frame.getGraphicsConfiguration();
        }

        public Point getLocation() {
            return frame.getLocation();
        }

        @Override
        public void setLocation(Point p) {
            frame.setLocation(p);
        }

        @Override
        public Dimension getSize() {
            return frame.getSize();
        }

        @Override
        public void setSize(Dimension size) {
            frame.setSize(size);
        }

        @Override
        public synchronized void addComponentListener(ComponentListener l) {
            frame.addComponentListener(l);
        }

        @Override
        public synchronized void removeComponentListener(ComponentListener l) {
            frame.addComponentListener(l);
        }

    });
    setPathName(pathName);
}

From source file:WindowEventDemo.java

public void checkWM() {
    Toolkit tk = frame.getToolkit();
    if (!(tk.isFrameStateSupported(Frame.ICONIFIED))) {
        displayMessage("Your window manager doesn't support ICONIFIED.");
    }/*from ww  w. j ava  2s.  c o  m*/
    if (!(tk.isFrameStateSupported(Frame.MAXIMIZED_VERT))) {
        displayMessage("Your window manager doesn't support MAXIMIZED_VERT.");
    }
    if (!(tk.isFrameStateSupported(Frame.MAXIMIZED_HORIZ))) {
        displayMessage("Your window manager doesn't support MAXIMIZED_HORIZ.");
    }
    if (!(tk.isFrameStateSupported(Frame.MAXIMIZED_BOTH))) {
        displayMessage("Your window manager doesn't support MAXIMIZED_BOTH.");
    } else {
        displayMessage("Your window manager supports MAXIMIZED_BOTH.");
    }
}

From source file:mergedoc.ui.MergeDocFrame.java

/**
 * ??????//ww  w.java  2 s . co m
 * @throws MergeDocException ?????
 */
private void initComponent() throws MergeDocException {

    // ????
    preferencePanel = new PreferencePanel();
    mergeManager = new MergeManager();

    // ???
    mainPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.X_AXIS));
    mainPanel.add(preferencePanel);

    // ??????
    JPanel outerPanel = new JPanel();
    outerPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    outerPanel.setLayout(new BoxLayout(outerPanel, BoxLayout.Y_AXIS));
    outerPanel.add(mainPanel);
    outerPanel.add(ComponentFactory.createSpacer(0, 7));
    outerPanel.add(buttonBar);
    getContentPane().add(outerPanel);

    // ?
    initListener();
    buttonBar.setState(buttonBar.INIT_STATE);

    // 
    ConfigManager config = ConfigManager.getInstance();
    String iconPath = config.getFile("icon.png").toString();
    Image icon = Toolkit.getDefaultToolkit().createImage(iconPath);
    setIconImage(icon);

    // 
    setTitle(SETTING_TITLE);
    Persister psst = Persister.getInstance();
    setLocation(psst.getInt(Persister.WINDOW_X, 0), psst.getInt(Persister.WINDOW_Y, 0));
    setSize(psst.getInt(Persister.WINDOW_WIDTH, 700), psst.getInt(Persister.WINDOW_HEIGHT, 570));
    int state = psst.getInt(Persister.WINDOW_STATE, NORMAL);
    if ((state & Frame.ICONIFIED) != ICONIFIED) {
        setExtendedState(state);
    }
    setVisible(true);
}

From source file:WindowEventDemo.java

public void checkWM() {
    Toolkit tk = frame.getToolkit();
    if (!(tk.isFrameStateSupported(Frame.ICONIFIED))) {
        displayMessage("Your window manager doesn't support ICONIFIED.");
    } else/*from  w w  w  . ja v a2 s  . c  o m*/
        displayMessage("Your window manager supports ICONIFIED.");
    if (!(tk.isFrameStateSupported(Frame.MAXIMIZED_VERT))) {
        displayMessage("Your window manager doesn't support MAXIMIZED_VERT.");
    } else
        displayMessage("Your window manager supports MAXIMIZED_VERT.");
    if (!(tk.isFrameStateSupported(Frame.MAXIMIZED_HORIZ))) {
        displayMessage("Your window manager doesn't support MAXIMIZED_HORIZ.");
    } else
        displayMessage("Your window manager supports MAXIMIZED_HORIZ.");
    if (!(tk.isFrameStateSupported(Frame.MAXIMIZED_BOTH))) {
        displayMessage("Your window manager doesn't support MAXIMIZED_BOTH.");
    } else {
        displayMessage("Your window manager supports MAXIMIZED_BOTH.");
    }
}

From source file:fr.jmmc.jmcs.logging.LogbackGui.java

/**
 * Display the logger editor//w  w w  .j av a 2s.c  o m
 * @param parent parent frame used to center this window (null means center on screen)
 * @param name name of the editor frame
 * @param loggerPath logger path
 */
public static void showWindow(final JFrame parent, final String name, final String loggerPath) {
    if (_guiFrameSingleton != null) {
        _guiFrameSingleton.toFront();

        // ensure window is visible (not iconified):
        if (_guiFrameSingleton.getState() == Frame.ICONIFIED) {
            _guiFrameSingleton.setState(Frame.NORMAL);
        }

        // force the frame to be visible and bring it to front
        _guiFrameSingleton.setVisible(true);
        _guiFrameSingleton.toFront();
    } else {
        final String frameName = (name != null) ? name : "Log Console";

        // Create Gui:
        _guiSingleton = new LogbackGui();

        // 1. Create the frame
        _guiFrameSingleton = new JFrame(frameName) {
            /** default serial UID for Serializable interface */
            private static final long serialVersionUID = 1L;

            /**
             * Free any resource or reference to this instance :
             * stop the Swing timer if started
             */
            @Override
            public void dispose() {
                // free LogbackGui resources:
                _guiSingleton.onDispose();

                // free singletons:
                _guiSingleton = null;
                _guiFrameSingleton = null;

                // dispose Frame :
                super.dispose();
            }
        };

        final Dimension dim = new Dimension(700, 500);
        _guiFrameSingleton.setMinimumSize(dim);
        _guiFrameSingleton.addComponentListener(new ComponentResizeAdapter(dim));

        // 2. Optional: What happens when the frame closes ?
        _guiFrameSingleton.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

        // 3. Create components and put them in the frame
        _guiFrameSingleton.add(_guiSingleton);

        // 4. Size the frame.
        _guiFrameSingleton.pack();

        // Center it :
        WindowUtils.centerOnMainScreen(_guiFrameSingleton);
        WindowUtils.setClosingKeyboardShortcuts(_guiFrameSingleton);

        // 5. Show it and waits until frame is not visible or disposed :
        _guiFrameSingleton.setVisible(true);
    }

    // Select the log tab:
    _guiSingleton.selectLogTab(loggerPath);
}

From source file:WindowEventDemo.java

String convertStateToString(int state) {
    if (state == Frame.NORMAL) {
        return "NORMAL";
    }//from   w  w  w. j a  v a  2  s.  c o m
    if ((state & Frame.ICONIFIED) != 0) {
        return "ICONIFIED";
    }
    //MAXIMIZED_BOTH is a concatenation of two bits, so
    //we need to test for an exact match.
    if ((state & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) {
        return "MAXIMIZED_BOTH";
    }
    if ((state & Frame.MAXIMIZED_VERT) != 0) {
        return "MAXIMIZED_VERT";
    }
    if ((state & Frame.MAXIMIZED_HORIZ) != 0) {
        return "MAXIMIZED_HORIZ";
    }
    return "UNKNOWN";
}

From source file:events.WindowEventDemo.java

private String convertStateToString(int state) {
    if (state == Frame.NORMAL) {
        return "NORMAL";
    }/*w w  w.  jav a 2s.com*/
    String strState = " ";
    if ((state & Frame.ICONIFIED) != 0) {
        strState += "ICONIFIED";
    }
    //MAXIMIZED_BOTH is a concatenation of two bits, so
    //we need to test for an exact match.
    if ((state & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) {
        strState += "MAXIMIZED_BOTH";
    } else {
        if ((state & Frame.MAXIMIZED_VERT) != 0) {
            strState += "MAXIMIZED_VERT";
        }
        if ((state & Frame.MAXIMIZED_HORIZ) != 0) {
            strState += "MAXIMIZED_HORIZ";
        }
    }
    if (" ".equals(strState)) {
        strState = "UNKNOWN";
    }
    return strState.trim();
}

From source file:WindowEventDemo.java

private String convertStateToString(int state) {
    if (state == Frame.NORMAL) {
        return "NORMAL";
    }//from w w w.  ja  v a  2s  . co  m
    String strState = " ";
    if ((state & Frame.ICONIFIED) != 0) {
        strState += "ICONIFIED";
    }
    // MAXIMIZED_BOTH is a concatenation of two bits, so
    // we need to test for an exact match.
    if ((state & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) {
        strState += "MAXIMIZED_BOTH";
    } else {
        if ((state & Frame.MAXIMIZED_VERT) != 0) {
            strState += "MAXIMIZED_VERT";
        }
        if ((state & Frame.MAXIMIZED_HORIZ) != 0) {
            strState += "MAXIMIZED_HORIZ";
        }
    }
    if (" ".equals(strState)) {
        strState = "UNKNOWN";
    }
    return strState.trim();
}

From source file:edu.umd.cs.findbugs.gui2.GUISaveState.java

public void setExtendedWindowState(int extendedWindowState) {
    this.extendedWindowState = extendedWindowState & ~Frame.ICONIFIED; // never save iconified state
}

From source file:edu.ku.brc.specify.tasks.subpane.wb.WorkbenchPaneSS.java

/**
 * Constructs the pane for the spreadsheet.
 * //from w  w w. j a  v  a2s  .c  o m
 * @param name the name of the pane
 * @param task the owning task
 * @param workbench the workbench to be edited
 * @param showImageView shows image window when first showing the window
 */
public WorkbenchPaneSS(final String name, final Taskable task, final Workbench workbenchArg,
        final boolean showImageView, final boolean isReadOnly) throws Exception {
    super(name, task);

    removeAll();

    if (workbenchArg == null) {
        return;
    }
    this.workbench = workbenchArg;

    this.isReadOnly = isReadOnly;

    headers.addAll(workbench.getWorkbenchTemplate().getWorkbenchTemplateMappingItems());
    Collections.sort(headers);

    boolean hasOneOrMoreImages = false;
    // pre load all the data
    for (WorkbenchRow wbRow : workbench.getWorkbenchRows()) {
        for (WorkbenchDataItem wbdi : wbRow.getWorkbenchDataItems()) {
            wbdi.getCellData();
        }

        if (wbRow.getWorkbenchRowImages() != null && wbRow.getWorkbenchRowImages().size() > 0) {
            hasOneOrMoreImages = true;
        }
    }

    model = new GridTableModel(this);
    spreadSheet = new WorkbenchSpreadSheet(model, this);
    spreadSheet.setReadOnly(isReadOnly);
    model.setSpreadSheet(spreadSheet);

    Highlighter simpleStriping = HighlighterFactory.createSimpleStriping();
    GridCellHighlighter hl = new GridCellHighlighter(
            new GridCellPredicate(GridCellPredicate.AnyPredicate, null));
    Short[] errs = { WorkbenchDataItem.VAL_ERROR, WorkbenchDataItem.VAL_ERROR_EDIT };
    ColorHighlighter errColorHighlighter = new ColorHighlighter(
            new GridCellPredicate(GridCellPredicate.ValidationPredicate, errs),
            CellRenderingAttributes.errorBackground, null);
    Short[] newdata = { WorkbenchDataItem.VAL_NEW_DATA };
    ColorHighlighter noDataHighlighter = new ColorHighlighter(
            new GridCellPredicate(GridCellPredicate.MatchingPredicate, newdata),
            CellRenderingAttributes.newDataBackground, null);
    Short[] multimatch = { WorkbenchDataItem.VAL_MULTIPLE_MATCH };
    ColorHighlighter multiMatchHighlighter = new ColorHighlighter(
            new GridCellPredicate(GridCellPredicate.MatchingPredicate, multimatch),
            CellRenderingAttributes.multipleMatchBackground, null);

    spreadSheet.setHighlighters(simpleStriping, hl, errColorHighlighter, noDataHighlighter,
            multiMatchHighlighter);

    //add key mappings for cut, copy, paste
    //XXX Note: these are shortcuts directly to the SpreadSheet cut,copy,paste methods, NOT to the Specify edit menu.
    addRecordKeyMappings(spreadSheet, KeyEvent.VK_C, "Copy", new AbstractAction() {
        public void actionPerformed(ActionEvent ae) {
            SwingUtilities.invokeLater(new Runnable() {

                /* (non-Javadoc)
                 * @see java.lang.Runnable#run()
                 */
                @Override
                public void run() {
                    spreadSheet.cutOrCopy(false);
                }
            });
        }
    }, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
    addRecordKeyMappings(spreadSheet, KeyEvent.VK_X, "Cut", new AbstractAction() {
        public void actionPerformed(ActionEvent ae) {
            SwingUtilities.invokeLater(new Runnable() {

                /* (non-Javadoc)
                 * @see java.lang.Runnable#run()
                 */
                @Override
                public void run() {
                    spreadSheet.cutOrCopy(true);
                }
            });
        }
    }, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
    addRecordKeyMappings(spreadSheet, KeyEvent.VK_V, "Paste", new AbstractAction() {
        public void actionPerformed(ActionEvent ae) {
            SwingUtilities.invokeLater(new Runnable() {

                /* (non-Javadoc)
                 * @see java.lang.Runnable#run()
                 */
                @Override
                public void run() {
                    spreadSheet.paste();
                }
            });
        }
    }, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());

    findPanel = spreadSheet.getFindReplacePanel();
    UIRegistry.getLaunchFindReplaceAction().setSearchReplacePanel(findPanel);

    spreadSheet.setShowGrid(true);
    JTableHeader header = spreadSheet.getTableHeader();
    header.addMouseListener(new ColumnHeaderListener());
    header.setReorderingAllowed(false); // Turn Off column dragging

    // Put the model in image mode, and never change it.
    // Now we're showing/hiding the image column using JXTable's column hiding features.
    model.setInImageMode(true);
    int imageColIndex = model.getColumnCount() - 1;
    imageColExt = spreadSheet.getColumnExt(imageColIndex);
    imageColExt.setVisible(false);

    int sgrColIndex = model.getSgrHeading().getViewOrder();
    sgrColExt = spreadSheet.getColumnExt(sgrColIndex);
    sgrColExt.setComparator(((WorkbenchSpreadSheet) spreadSheet).new NumericColumnComparator());

    int cmpIdx = 0;
    for (Comparator<String> cmp : ((WorkbenchSpreadSheet) spreadSheet).getComparators()) {
        if (cmp != null) {
            spreadSheet.getColumnExt(cmpIdx++).setComparator(cmp);
        }
    }

    // Start off with the SGR score column hidden
    showHideSgrCol(false);

    model.addTableModelListener(new TableModelListener() {
        public void tableChanged(TableModelEvent e) {
            setChanged(true);
        }
    });

    spreadSheet.addFocusListener(new FocusAdapter() {
        @Override
        public void focusGained(FocusEvent e) {
            UIRegistry.enableCutCopyPaste(true);
            UIRegistry.enableFind(findPanel, true);
        }

        @Override
        public void focusLost(FocusEvent e) {
            UIRegistry.enableCutCopyPaste(true);
            UIRegistry.enableFind(findPanel, true);
        }
    });

    if (isReadOnly) {
        saveBtn = null;
    } else {
        saveBtn = createButton(getResourceString("SAVE"));
        saveBtn.setToolTipText(
                String.format(getResourceString("WB_SAVE_DATASET_TT"), new Object[] { workbench.getName() }));
        saveBtn.setEnabled(false);
        saveBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                UsageTracker.incrUsageCount("WB.SaveDataSet");

                UIRegistry.writeSimpleGlassPaneMsg(
                        String.format(getResourceString("WB_SAVING"), new Object[] { workbench.getName() }),
                        WorkbenchTask.GLASSPANE_FONT_SIZE);
                UIRegistry.getStatusBar().setIndeterminate(workbench.getName(), true);
                final SwingWorker worker = new SwingWorker() {
                    @SuppressWarnings("synthetic-access")
                    @Override
                    public Object construct() {
                        try {
                            saveObject();

                        } catch (Exception ex) {
                            UsageTracker.incrHandledUsageCount();
                            edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(WorkbenchPaneSS.class,
                                    ex);
                            log.error(ex);
                            return ex;
                        }
                        return null;
                    }

                    // Runs on the event-dispatching thread.
                    @Override
                    public void finished() {
                        Object retVal = get();
                        if (retVal != null && retVal instanceof Exception) {
                            Exception ex = (Exception) retVal;
                            UIRegistry.getStatusBar().setErrorMessage(getResourceString("WB_ERROR_SAVING"), ex);
                        }

                        UIRegistry.clearSimpleGlassPaneMsg();
                        UIRegistry.getStatusBar().setProgressDone(workbench.getName());
                    }
                };
                worker.start();

            }
        });
    }

    Action delAction = addRecordKeyMappings(spreadSheet, KeyEvent.VK_F3, "DelRow", new AbstractAction() {
        public void actionPerformed(ActionEvent ae) {
            if (validationWorkerQueue.peek() == null) {
                deleteRows();
            }
        }
    }, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());

    if (isReadOnly) {
        deleteRowsBtn = null;
    } else {
        deleteRowsBtn = createIconBtn("DelRec", "WB_DELETE_ROW", delAction);
        selectionSensitiveButtons.add(deleteRowsBtn);
        spreadSheet.setDeleteAction(delAction);
    }

    //XXX Using the wb ID in the prefname to do pref setting per wb, may result in a bloated prefs file?? 
    doIncrementalValidation = AppPreferences.getLocalPrefs()
            .getBoolean(wbAutoValidatePrefName + "." + workbench.getId(), true);
    doIncrementalMatching = AppPreferences.getLocalPrefs()
            .getBoolean(wbAutoMatchPrefName + "." + workbench.getId(), false);

    if (isReadOnly) {
        clearCellsBtn = null;
    } else {
        clearCellsBtn = createIconBtn("Eraser", "WB_CLEAR_CELLS", new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                spreadSheet.clearSorter();

                if (spreadSheet.getCellEditor() != null) {
                    spreadSheet.getCellEditor().stopCellEditing();
                }
                int[] rows = spreadSheet.getSelectedRowModelIndexes();
                int[] cols = spreadSheet.getSelectedColumnModelIndexes();
                model.clearCells(rows, cols);
            }
        });
        selectionSensitiveButtons.add(clearCellsBtn);
    }

    Action addAction = addRecordKeyMappings(spreadSheet, KeyEvent.VK_N, "AddRow", new AbstractAction() {
        public void actionPerformed(ActionEvent ae) {
            if (workbench.getWorkbenchRows().size() < WorkbenchTask.MAX_ROWS) {
                if (validationWorkerQueue.peek() == null) {
                    addRowAfter();
                }
            }
        }
    }, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());

    if (isReadOnly) {
        addRowsBtn = null;
    } else {
        addRowsBtn = createIconBtn("AddRec", "WB_ADD_ROW", addAction);
        addRowsBtn.setEnabled(true);
        addAction.setEnabled(true);
    }

    if (isReadOnly) {
        carryForwardBtn = null;
    } else {
        carryForwardBtn = createIconBtn("CarryForward20x20", IconManager.IconSize.NonStd, "WB_CARRYFORWARD",
                false, new ActionListener() {
                    public void actionPerformed(ActionEvent ae) {
                        UsageTracker.getUsageCount("WBCarryForward");

                        configCarryFoward();
                    }
                });
        carryForwardBtn.setEnabled(true);
    }

    toggleImageFrameBtn = createIconBtn("CardImage", IconManager.IconSize.NonStd, "WB_SHOW_IMG_WIN", false,
            new ActionListener() {
                public void actionPerformed(ActionEvent ae) {
                    toggleImageFrameVisible();
                }
            });
    toggleImageFrameBtn.setEnabled(true);

    importImagesBtn = createIconBtn("CardImage", IconManager.IconSize.NonStd, "WB_SHOW_IMG_WIN", false,
            new ActionListener() {
                public void actionPerformed(ActionEvent ae) {
                    toggleImportImageFrameVisible();
                }
            });
    importImagesBtn.setEnabled(true);

    /*showMapBtn = createIconBtn("ShowMap", IconManager.IconSize.NonStd, "WB_SHOW_MAP", false, new ActionListener()
    {
    public void actionPerformed(ActionEvent ae)
    {
        showMapOfSelectedRecords();
    }
    });*/
    // enable or disable along with Google Earth and Geo Ref Convert buttons

    if (isReadOnly) {
        exportKmlBtn = null;
    } else {
        exportKmlBtn = createIconBtn("GoogleEarth", IconManager.IconSize.NonStd, "WB_SHOW_IN_GOOGLE_EARTH",
                false, new ActionListener() {
                    public void actionPerformed(ActionEvent ae) {
                        SwingUtilities.invokeLater(new Runnable() {
                            public void run() {
                                showRecordsInGoogleEarth();
                            }
                        });
                    }
                });
    }

    // 

    readRegisteries();

    // enable or disable along with Show Map and Geo Ref Convert buttons

    if (isReadOnly) {
        geoRefToolBtn = null;
    } else {
        AppPreferences remotePrefs = AppPreferences.getRemote();
        final String tool = remotePrefs.get("georef_tool", "geolocate");
        String iconName = "GEOLocate20"; //tool.equalsIgnoreCase("geolocate") ? "GeoLocate" : "BioGeoMancer";
        String toolTip = tool.equalsIgnoreCase("geolocate") ? "WB_DO_GEOLOCATE_LOOKUP"
                : "WB_DO_BIOGEOMANCER_LOOKUP";
        geoRefToolBtn = createIconBtn(iconName, IconManager.IconSize.NonStd, toolTip, false,
                new ActionListener() {
                    public void actionPerformed(ActionEvent ae) {
                        spreadSheet.clearSorter();

                        if (tool.equalsIgnoreCase("geolocate")) {
                            doGeoRef(new edu.ku.brc.services.geolocate.prototype.GeoCoordGeoLocateProvider(),
                                    "WB.GeoLocateRows");
                        } else {
                            doGeoRef(new GeoCoordBGMProvider(), "WB.BioGeomancerRows");
                        }
                    }
                });
        // only enable it if the workbench has the proper columns in it
        String[] missingColumnsForBG = getMissingButRequiredColumnsForGeoRefTool(tool);
        if (missingColumnsForBG.length > 0) {
            geoRefToolBtn.setEnabled(false);
            String ttText = "<p>" + getResourceString("WB_ADDITIONAL_FIELDS_REQD") + ":<ul>";
            for (String reqdField : missingColumnsForBG) {
                ttText += "<li>" + reqdField + "</li>";
            }
            ttText += "</ul>";
            String origTT = geoRefToolBtn.getToolTipText();
            geoRefToolBtn.setToolTipText("<html>" + origTT + ttText);
        } else {
            geoRefToolBtn.setEnabled(true);
        }
    }

    if (isReadOnly) {
        convertGeoRefFormatBtn = null;
    } else {
        convertGeoRefFormatBtn = createIconBtn("ConvertGeoRef", IconManager.IconSize.NonStd,
                "WB_CONVERT_GEO_FORMAT", false, new ActionListener() {
                    public void actionPerformed(ActionEvent ae) {
                        showGeoRefConvertDialog();
                    }
                });

        // now enable/disable the geo ref related buttons
        String[] missingGeoRefFields = getMissingGeoRefLatLonFields();
        if (missingGeoRefFields.length > 0) {
            convertGeoRefFormatBtn.setEnabled(false);
            exportKmlBtn.setEnabled(false);
            //showMapBtn.setEnabled(false);

            String ttText = "<p>" + getResourceString("WB_ADDITIONAL_FIELDS_REQD") + ":<ul>";
            for (String reqdField : missingGeoRefFields) {
                ttText += "<li>" + reqdField + "</li>";
            }
            ttText += "</ul>";
            String origTT1 = convertGeoRefFormatBtn.getToolTipText();
            convertGeoRefFormatBtn.setToolTipText("<html>" + origTT1 + ttText);
            String origTT2 = exportKmlBtn.getToolTipText();
            exportKmlBtn.setToolTipText("<html>" + origTT2 + ttText);
            //String origTT3 = showMapBtn.getToolTipText();
            //showMapBtn.setToolTipText("<html>" + origTT3 + ttText);
        } else {
            convertGeoRefFormatBtn.setEnabled(true);
            exportKmlBtn.setEnabled(true);
            //showMapBtn.setEnabled(true);
        }
    }

    if (AppContextMgr.isSecurityOn() && !task.getPermissions().canModify()) {
        exportExcelCsvBtn = null;
    } else {
        exportExcelCsvBtn = createIconBtn("Export", IconManager.IconSize.NonStd, "WB_EXPORT_DATA", false,
                new ActionListener() {
                    public void actionPerformed(ActionEvent ae) {
                        doExcelCsvExport();
                    }
                });
        exportExcelCsvBtn.setEnabled(true);
    }

    uploadDatasetBtn = createIconBtn("Upload", IconManager.IconSize.Std24, "WB_UPLOAD_DATA", false,
            new ActionListener() {
                public void actionPerformed(ActionEvent ae) {
                    doDatasetUpload();
                }
            });
    uploadDatasetBtn.setVisible(isUploadPermitted() && !UIRegistry.isMobile());
    uploadDatasetBtn.setEnabled(canUpload());
    if (!uploadDatasetBtn.isEnabled()) {
        uploadDatasetBtn.setToolTipText(getResourceString("WB_UPLOAD_IN_PROGRESS"));
    }

    // listen to selection changes to enable/disable certain buttons
    spreadSheet.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                JStatusBar statusBar = UIRegistry.getStatusBar();
                statusBar.setText("");

                currentRow = spreadSheet.getSelectedRow();
                updateBtnUI();
            }
        }
    });

    for (int c = 0; c < spreadSheet.getTableHeader().getColumnModel().getColumnCount(); c++) {
        // TableColumn column =
        // spreadSheet.getTableHeader().getColumnModel().getColumn(spreadSheet.getTableHeader().getColumnModel().getColumnCount()-1);
        TableColumn column = spreadSheet.getTableHeader().getColumnModel().getColumn(c);
        column.setCellRenderer(new WbCellRenderer());
    }

    // setup the JFrame to show images attached to WorkbenchRows
    imageFrame = new ImageFrame(mapSize, this, this.workbench, task, isReadOnly);

    // setup the JFrame to show images attached to WorkbenchRows
    imageImportFrame = new ImageImportFrame(this, this.workbench);

    setupWorkbenchRowChangeListener();

    // setup window minimizing/maximizing listener
    JFrame topFrame = (JFrame) UIRegistry.getTopWindow();
    minMaxWindowListener = new WindowAdapter() {
        @Override
        public void windowDeiconified(WindowEvent e) {
            if (imageFrame != null && imageFrame.isVisible()) {
                imageFrame.setExtendedState(Frame.NORMAL);
            }
            if (mapFrame != null && mapFrame.isVisible()) {
                mapFrame.setExtendedState(Frame.NORMAL);
            }
        }

        @Override
        public void windowIconified(WindowEvent e) {
            if (imageFrame != null && imageFrame.isVisible()) {
                imageFrame.setExtendedState(Frame.ICONIFIED);
            }
            if (mapFrame != null && mapFrame.isVisible()) {
                mapFrame.setExtendedState(Frame.ICONIFIED);
            }
        }
    };
    topFrame.addWindowListener(minMaxWindowListener);

    if (!isReadOnly) {
        showHideUploadToolBtn = createIconBtn("ValidateWB", IconManager.IconSize.NonStd,
                "WB_HIDE_UPLOADTOOLPANEL", false, new ActionListener() {
                    public void actionPerformed(ActionEvent ae) {
                        if (uploadToolPanel.isExpanded()) {
                            hideUploadToolPanel();
                            showHideUploadToolBtn.setToolTipText(getResourceString("WB_SHOW_UPLOADTOOLPANEL"));
                        } else {
                            showUploadToolPanel();
                            showHideUploadToolBtn.setToolTipText(getResourceString("WB_HIDE_UPLOADTOOLPANEL"));
                        }
                    }
                });
        showHideUploadToolBtn.setEnabled(true);
    }

    // setup the mapping features
    mapFrame = new JFrame();
    mapFrame.setIconImage(IconManager.getImage("AppIcon").getImage());
    mapFrame.setTitle(getResourceString("WB_GEO_REF_DATA_MAP"));
    mapImageLabel = createLabel("");
    mapImageLabel.setSize(500, 500);
    mapFrame.add(mapImageLabel);
    mapFrame.setSize(500, 500);

    // start putting together the visible UI
    CellConstraints cc = new CellConstraints();

    JComponent[] compsArray = { addRowsBtn, deleteRowsBtn, clearCellsBtn, /*showMapBtn,*/ exportKmlBtn,
            geoRefToolBtn, convertGeoRefFormatBtn, exportExcelCsvBtn, uploadDatasetBtn, showHideUploadToolBtn };
    Vector<JComponent> availableComps = new Vector<JComponent>(
            compsArray.length + workBenchPluginSSBtns.size());
    for (JComponent c : compsArray) {
        if (c != null) {
            availableComps.add(c);
        }
    }
    for (JComponent c : workBenchPluginSSBtns) {
        availableComps.add(c);
    }

    PanelBuilder spreadSheetControlBar = new PanelBuilder(new FormLayout(
            "f:p:g,4px," + createDuplicateJGoodiesDef("p", "4px", availableComps.size()) + ",4px,", "c:p:g"));

    int x = 3;
    for (JComponent c : availableComps) {
        spreadSheetControlBar.add(c, cc.xy(x, 1));
        x += 2;
    }

    int h = 0;
    Vector<WorkbenchTemplateMappingItem> headers = new Vector<WorkbenchTemplateMappingItem>();
    headers.addAll(workbench.getWorkbenchTemplate().getWorkbenchTemplateMappingItems());
    Collections.sort(headers);
    for (WorkbenchTemplateMappingItem mi : headers) {
        //using the workbench data model table. Not the actual specify table the column is mapped to.
        //This MIGHT be less confusing
        //System.out.println("setting header renderer for " + mi.getTableName() + "." + mi.getFieldName()); 
        spreadSheet.getColumnModel().getColumn(h++)
                .setHeaderRenderer(new WbTableHeaderRenderer(mi.getTableName()));
    }

    // NOTE: This needs to be done after the creation of the saveBtn. And after the creation of the header renderes.
    initColumnSizes(spreadSheet, saveBtn);

    // Create the Form Pane  -- needs to be done after initColumnSizes - which also sets cell editors for collumns
    if (task instanceof SGRTask) {
        formPane = new SGRFormPane(this, workbench, isReadOnly);
    } else {
        formPane = new FormPane(this, workbench, isReadOnly);
    }

    // This panel contains just the ResultSetContoller, it's needed so the RSC gets centered
    PanelBuilder rsPanel = new PanelBuilder(new FormLayout("c:p:g", "c:p:g"));
    FormValidator dummy = new FormValidator(null);
    dummy.setEnabled(true);
    resultsetController = new ResultSetController(dummy, !isReadOnly, !isReadOnly, false,
            getResourceString("Record"), model.getRowCount(), true);
    resultsetController.addListener(formPane);
    if (!isReadOnly) {
        resultsetController.getDelRecBtn().addActionListener(delAction);
    }
    //        else
    //        {
    //            resultsetController.getDelRecBtn().setVisible(false);
    //        }
    rsPanel.add(resultsetController.getPanel(), cc.xy(1, 1));

    // This panel is a single row containing the ResultSetContoller and the other controls for the Form Panel
    String colspec = "f:p:g, p, f:p:g, p";
    for (int i = 0; i < workBenchPluginFormBtns.size(); i++) {
        colspec = colspec + ", f:p, p";
    }

    PanelBuilder resultSetPanel = new PanelBuilder(new FormLayout(colspec, "c:p:g"));
    // Now put the two panel into the single row panel
    resultSetPanel.add(rsPanel.getPanel(), cc.xy(2, 1));
    if (!isReadOnly) {
        resultSetPanel.add(formPane.getControlPropsBtn(), cc.xy(4, 1));
    }
    int ccx = 6;
    for (JComponent c : workBenchPluginFormBtns) {
        resultSetPanel.add(c, cc.xy(ccx, 1));
        ccx += 2;
    }

    // Create the main panel that uses card layout for the form and spreasheet
    mainPanel = new JPanel(cardLayout = new CardLayout());

    // Add the Form and Spreadsheet to the CardLayout
    mainPanel.add(spreadSheet.getScrollPane(), PanelType.Spreadsheet.toString());
    mainPanel.add(formPane.getPane(), PanelType.Form.toString());

    // The controllerPane is a CardLayout that switches between the Spreadsheet control bar and the Form Control Bar
    controllerPane = new JPanel(cpCardLayout = new CardLayout());
    controllerPane.add(spreadSheetControlBar.getPanel(), PanelType.Spreadsheet.toString());
    controllerPane.add(resultSetPanel.getPanel(), PanelType.Form.toString());

    JLabel sep1 = new JLabel(IconManager.getIcon("Separator"));
    JLabel sep2 = new JLabel(IconManager.getIcon("Separator"));
    ssFormSwitcher = createSwitcher();

    // This works
    setLayout(new BorderLayout());

    boolean doDnDImages = AppPreferences.getLocalPrefs().getBoolean("WB_DND_IMAGES", false);
    JComponent[] ctrlCompArray1 = { importImagesBtn, toggleImageFrameBtn, carryForwardBtn, sep1, saveBtn, sep2,
            ssFormSwitcher };
    JComponent[] ctrlCompArray2 = { toggleImageFrameBtn, carryForwardBtn, sep1, saveBtn, sep2, ssFormSwitcher };
    JComponent[] ctrlCompArray = doDnDImages ? ctrlCompArray1 : ctrlCompArray2;

    Vector<Pair<JComponent, Integer>> ctrlComps = new Vector<Pair<JComponent, Integer>>();
    for (JComponent c : ctrlCompArray) {
        ctrlComps.add(new Pair<JComponent, Integer>(c, null));
    }

    String layoutStr = "";
    int compCount = 0;
    int col = 1;
    int pos = 0;
    for (Pair<JComponent, Integer> c : ctrlComps) {
        JComponent comp = c.getFirst();
        if (comp != null) {
            boolean addComp = !(comp == sep1 || comp == sep2) || compCount > 0;
            if (!addComp) {
                c.setFirst(null);
            } else {
                if (!StringUtils.isEmpty(layoutStr)) {
                    layoutStr += ",";
                    col++;
                    if (pos < ctrlComps.size() - 1) {
                        //this works because we know ssFormSwitcher is last and always non-null.
                        layoutStr += "6px,";
                        col++;
                    }
                }
                c.setSecond(col);
                if (comp == sep1 || comp == sep2) {
                    layoutStr += "6px";
                    compCount = 0;
                } else {
                    layoutStr += "p";
                    compCount++;
                }
            }
        }
        pos++;
    }
    PanelBuilder ctrlBtns = new PanelBuilder(new FormLayout(layoutStr, "c:p:g"));
    for (Pair<JComponent, Integer> c : ctrlComps) {
        if (c.getFirst() != null) {
            ctrlBtns.add(c.getFirst(), cc.xy(c.getSecond(), 1));
        }
    }

    add(mainPanel, BorderLayout.CENTER);

    FormLayout formLayout = new FormLayout("f:p:g,4px,p", "2px,f:p:g,p:g,p:g");
    PanelBuilder builder = new PanelBuilder(formLayout);

    builder.add(controllerPane, cc.xy(1, 2));
    builder.add(ctrlBtns.getPanel(), cc.xy(3, 2));

    if (!isReadOnly) {
        uploadToolPanel = new UploadToolPanel(this, UploadToolPanel.EXPANDED);
        uploadToolPanel.createUI();
        //            showHideUploadToolBtn = createIconBtn("ValidateWB", IconManager.IconSize.NonStd, "WB_HIDE_UPLOADTOOLPANEL", false, new ActionListener()
        //            {
        //                public void actionPerformed(ActionEvent ae)
        //                {
        //                    if (uploadToolPanel.isExpanded())
        //                    {
        //                       hideUploadToolPanel();
        //                       showHideUploadToolBtn.setToolTipText(getResourceString("WB_SHOW_UPLOADTOOLPANEL"));
        //                    } else
        //                    {
        //                       showUploadToolPanel();
        //                       showHideUploadToolBtn.setToolTipText(getResourceString("WB_HIDE_UPLOADTOOLPANEL"));
        //                   }
        //                }
        //            });
        //            showHideUploadToolBtn.setEnabled(true);
    }

    builder.add(uploadToolPanel, cc.xywh(1, 3, 3, 1));
    builder.add(findPanel, cc.xywh(1, 4, 3, 1));

    add(builder.getPanel(), BorderLayout.SOUTH);

    resultsetController.addListener(new ResultSetControllerListener() {
        public boolean indexAboutToChange(int oldIndex, int newIndex) {
            return true;
        }

        public void indexChanged(int newIndex) {
            if (imageFrame != null) {
                if (newIndex > -1) {
                    int index = spreadSheet.convertRowIndexToModel(newIndex);
                    imageFrame.setRow(workbench.getRow(index));
                } else {
                    imageFrame.setRow(null);
                }
            }
        }

        public void newRecordAdded() {
            // do nothing
        }
    });
    //compareSchemas();
    if (getIncremental() && workbenchValidator == null) {
        buildValidator();
    }

    //        int c = 0;
    //        Vector<WorkbenchTemplateMappingItem> headers = new Vector<WorkbenchTemplateMappingItem>();
    //        headers.addAll(workbench.getWorkbenchTemplate().getWorkbenchTemplateMappingItems());
    //        Collections.sort(headers);
    //        for (WorkbenchTemplateMappingItem mi : headers)
    //        {
    //           //using the workbench data model table. Not the actual specify table the column is mapped to.
    //           //This MIGHT be less confusing
    //           //System.out.println("setting header renderer for " + mi.getTableName() + "." + mi.getFieldName()); 
    //           spreadSheet.getColumnModel().getColumn(c++).setHeaderRenderer(new WbTableHeaderRenderer(mi.getTableName()));
    //        }
    //        
    //        // NOTE: This needs to be done after the creation of the saveBtn. And after the creation of the header renderes.
    //        initColumnSizes(spreadSheet, saveBtn);

    // See if we need to make the Image Frame visible
    // Commenting this out for now because it is so annoying.

    if (showImageView || hasOneOrMoreImages) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                toggleImageFrameVisible();

                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        final Frame f = (Frame) UIRegistry.get(UIRegistry.FRAME);
                        f.toFront();
                        f.requestFocus();
                    }
                });
            }
        });
    }

    ((WorkbenchTask) ContextMgr.getTaskByClass(WorkbenchTask.class)).opening(this);
    ((SGRTask) ContextMgr.getTaskByClass(SGRTask.class)).opening(this);
}