Example usage for javax.swing JToolBar repaint

List of usage examples for javax.swing JToolBar repaint

Introduction

In this page you can find the example usage for javax.swing JToolBar repaint.

Prototype

public void repaint() 

Source Link

Document

Repaints this component.

Usage

From source file:edu.ku.brc.specify.tasks.StartUpTask.java

/**
 * @param cmdAction//from   ww  w  .ja v a 2s  .c om
 */
protected void prefsChanged(final CommandAction cmdAction) {
    AppPreferences remotePrefs = (AppPreferences) cmdAction.getData();

    if (remotePrefs == AppPreferences.getRemote()) {
        String ds = AppContextMgr.getInstance().getClassObject(Discipline.class).getType();
        boolean hasWelcome = remotePrefs.getBoolean(WELCOME_BTN_PREF + "." + ds, true);

        JToolBar toolBar = (JToolBar) UIRegistry.get(UIRegistry.TOOLBAR);
        if (!hasWelcome) {
            indexOfTBB = toolBar.getComponentIndex(welcomeBtn);
            TaskMgr.removeToolbarBtn(welcomeBtn);
            toolBar.validate();
            toolBar.repaint();

        } else {
            int curInx = toolBar.getComponentIndex(welcomeBtn);
            if (curInx == -1) {
                int inx = indexOfTBB != -1 ? indexOfTBB : 0;
                TaskMgr.addToolbarBtn(welcomeBtn, inx);
                toolBar.validate();
                toolBar.repaint();
            }

            welcomeBtn.setIcon(IconManager.getIcon("InnerAppIcon", IconManager.IconSize.Std24));
        }
    }
}

From source file:edu.ku.brc.specify.tasks.BaseTask.java

/**
 * @param cmdAction//from w ww. j  a va2s .c om
 */
protected void reAddToolBarItem(final CommandAction cmdAction, final Component toolBarBtn,
        final String prefName) {
    AppPreferences remotePrefs = (AppPreferences) cmdAction.getData();
    if (remotePrefs == AppPreferences.getRemote()) {
        JToolBar toolBar = (JToolBar) UIRegistry.get(UIRegistry.TOOLBAR);
        Object value = cmdAction.getProperties().get(prefName);
        if (value != null && value instanceof Boolean) {
            //if (!remotePrefs.getBoolean(prefName, true))
            //{
            Boolean isChecked = (Boolean) value;
            if (!isChecked) {
                toolbarBtnIndex = toolBar.getComponentIndex(toolBarBtn);
                TaskMgr.removeToolbarBtn(toolBarBtn);
                toolBar.validate();
                toolBar.repaint();

            } else {
                int curInx = toolBar.getComponentIndex(toolBarBtn);
                if (curInx == -1) {
                    int lastInx = toolBar.getComponentCount() - 2;
                    int inx = toolbarBtnIndex != -1 && toolbarBtnIndex <= lastInx ? toolbarBtnIndex : lastInx;
                    TaskMgr.addToolbarBtn(toolBarBtn, inx);
                    toolBar.validate();
                    toolBar.repaint();
                }
            }
        }
    }
}

From source file:edu.ku.brc.specify.plugins.ipadexporter.iPadDBExporterPlugin.java

/**
 * /*from w  w w.j ava 2 s .com*/
 */
private void prefsChanged(final CommandAction cmdAction) {
    AppPreferences appPrefs = (AppPreferences) cmdAction.getData();

    if (appPrefs == AppPreferences.getRemote()) {
        // Note: The event send with the name of pref from the form
        // not the name that was saved. So we don't need to append the discipline name on the end
        Object value = cmdAction.getProperties().get(ON_TASKBAR);
        if (value != null && value instanceof Boolean) {
            /*
             * This doesn't work because it isn't added to the Toolbar correctly
             * */
            JToolBar toolBar = (JToolBar) get(TOOLBAR);

            Boolean isChecked = (Boolean) value;
            if (isChecked) {
                TaskMgr.addToolbarBtn(toolBarBtn, toolBar.getComponentCount() - 1);
            } else {
                TaskMgr.removeToolbarBtn(toolBarBtn);
            }
            toolBar.validate();
            toolBar.repaint();

        }
    }
}

From source file:freemind.controller.Controller.java

public void afterMapModuleChange(MapModule oldMapModule, Mode oldMode, MapModule newMapModule, Mode newMode) {
    ModeController newModeController;/*w w  w . ja va2 s. c  o  m*/
    if (newMapModule != null) {
        getFrame().setView(newMapModule.getView());
        setAllActions(true);
        if ((getView().getSelected() == null)) {
            moveToRoot();
        }
        lastOpened.mapOpened(newMapModule);
        ((MainToolBar) getToolbar()).setZoomComboBox(newMapModule.getView().getZoom());
        // old
        //            obtainFocusForSelected();
        newModeController = newMapModule.getModeController();
        newModeController.startupController();
        newModeController.setVisible(true);
        // old
        //            obtainFocusForSelected();
    } else {
        newModeController = newMode.getDefaultModeController();
        getFrame().setView(null);
        setAllActions(false);
    }
    setTitle();
    JToolBar newToolBar = newModeController.getModeToolBar();
    if (newToolBar != null) {
        toolbar.add(newToolBar);
        newToolBar.repaint();
    }
    /* new left toolbar. */
    Component newLeftToolBar = newModeController.getLeftToolBar();
    if (newLeftToolBar != null) {
        getFrame().getContentPane().add(newLeftToolBar, BorderLayout.WEST);
        if (leftToolbarVisible) {
            newLeftToolBar.setVisible(true);
            newLeftToolBar.repaint();
        } else {
            newLeftToolBar.setVisible(false);
        }
    }
    toolbar.validate();
    toolbar.repaint();
    MenuBar menuBar = getFrame().getFreeMindMenuBar();
    menuBar.updateMenus(newModeController);
    menuBar.revalidate();
    menuBar.repaint();
    // new
    obtainFocusForSelected();
}

From source file:edu.ku.brc.specify.tasks.InteractionsTask.java

@Override
public void doConfigure() {

    boolean isEmpty = infoRequestNavBox.getItems().size() == 0;

    Vector<TaskConfigItemIFace> stdList = new Vector<TaskConfigItemIFace>();
    Vector<TaskConfigItemIFace> miscList = new Vector<TaskConfigItemIFace>();
    Vector<TaskConfigItemIFace> srvList = new Vector<TaskConfigItemIFace>();

    boolean showIRBox = true;
    for (InteractionEntry entry : entries) {
        DBTableInfo tableInfo = DBTableIdMgr.getInstance().getInfoByTableName(entry.getTableName());
        if (!AppContextMgr.isSecurityOn() || tableInfo.getPermissions().canView()) {
            //System.err.println(entry.getName()+"\t  "+entry.isSearchService()+"   "+entry.isOnLeft()+"   "+entry.isVisible());
            entry.setEnabled(true);/*from   w  w  w.  java  2 s.  c  o m*/
            if (entry.isVisible()) {
                Vector<TaskConfigItemIFace> list = entry.isOnLeft() ? stdList : miscList;
                // Clone for undo (Cancel)
                try {
                    list.add((TaskConfigItemIFace) entry.clone());

                } catch (CloneNotSupportedException ex) {
                    /* ignore */}
            } else {
                srvList.add(entry);
            }
        } else {
            entry.setEnabled(false);

            if (tableInfo.getTableId() == infoRequestTableId) {
                showIRBox = false;
            }
        }
    }

    if (showIRBox) {
        navBoxes.add(infoRequestNavBox);
    } else {
        navBoxes.remove(infoRequestNavBox);
    }

    int origNumStd = stdList.size();

    TaskConfigureDlg dlg = new TaskConfigureDlg(stdList, miscList, false, "InteractionsConfig", "IAT_TITLE",
            "IAT_AVAIL_ITEMS", "IAT_HIDDEN_ITEMS", "IAT_MAKE_AVAIL", "IAT_MAKE_HIDDEN");
    dlg.setVisible(true);
    if (!dlg.isCancelled()) {
        entries.clear();
        for (TaskConfigItemIFace ie : stdList) {
            ((InteractionEntry) ie).setOnLeft(true);
            entries.add((InteractionEntry) ie);
        }

        for (TaskConfigItemIFace ie : miscList) {
            ((InteractionEntry) ie).setOnLeft(false);
            entries.add((InteractionEntry) ie);
        }

        for (TaskConfigItemIFace ie : srvList) {
            entries.add((InteractionEntry) ie);
        }

        writeEntries();

        actionsNavBox.clear();

        Collections.sort(entries);

        for (InteractionEntry entry : entries) {
            DBTableInfo tableInfo = DBTableIdMgr.getInstance().getInfoByTableName(entry.getTableName());
            if (entry.isEnabled()) {
                if (entry.isOnLeft()) {
                    NavBoxButton navBtn = addCommand(actionsNavBox, tableInfo, entry);
                    navBtn.setToolTip(entry.getI18NTooltip());

                } else if (StringUtils.isNotEmpty(entry.getViewName()) && !entry.isSearchService()) {
                    CommandAction cmdAction = createCmdActionFromEntry(entry, tableInfo);
                    ContextMgr.registerService(10, entry.getViewName(), tableInfo.getTableId(), cmdAction, this,
                            "Data_Entry", tableInfo.getTitle(), true); // the Name gets Hashed
                }
            }
        }

        NavBoxMgr.getInstance().validate();
        NavBoxMgr.getInstance().invalidate();
        NavBoxMgr.getInstance().doLayout();

        if (stdList.size() == 0) {
            String ds = AppContextMgr.getInstance().getClassObject(Discipline.class).getType();
            AppPreferences.getRemote().putBoolean(IS_USING_INTERACTIONS_PREFNAME + ds, false);
            JToolBar toolBar = (JToolBar) UIRegistry.get(UIRegistry.TOOLBAR);
            indexOfTBB = toolBar.getComponentIndex(toolBarBtn);
            if (indexOfTBB > -1) {
                TaskMgr.removeToolbarBtn(toolBarBtn);
                toolBar.validate();
                toolBar.repaint();
            }

        } else if (isEmpty && stdList.size() > 0) {
            String ds = AppContextMgr.getInstance().getClassObject(Discipline.class).getType();
            AppPreferences.getRemote().putBoolean(IS_USING_INTERACTIONS_PREFNAME + ds, true);
            prefsChanged(new CommandAction(null, null, AppPreferences.getRemote()));

            if (origNumStd == 0) {
                JToolBar toolBar = (JToolBar) UIRegistry.get(UIRegistry.TOOLBAR);
                int inx = indexOfTBB != -1 ? indexOfTBB : 4;
                TaskMgr.addToolbarBtn(toolBarBtn, inx);
                toolBar.validate();
                toolBar.repaint();
            }
        }
    }
}