Search in sources :

Example 1 with CompiereColor

use of org.compiere.plaf.CompiereColor in project adempiere by adempiere.

the class MColorTest method testQuery.

public void testQuery() throws Exception {
    //red1 put in dummy record that has COLORTYPE = 'R' for and ADImageID = 101
    MColor clr = new MColor(getCtx(), 1, getTrxName());
    CompiereColor url = clr.getAdempiereColor();
    assertTrue("Color must be right", url.toString().length() > 0);
}
Also used : CompiereColor(org.compiere.plaf.CompiereColor) MColor(org.compiere.model.MColor)

Example 2 with CompiereColor

use of org.compiere.plaf.CompiereColor in project adempiere by adempiere.

the class VColor method getAdempiereColor.

/*************************************************************************/
/**
	 *  Load Color from Tab
	 *  @return true if loaded
	 *  @see org.compiere.model.MColor#getAdempiereColor
	 */
private CompiereColor getAdempiereColor() {
    Integer AD_Color_ID = (Integer) m_mTab.getValue("AD_Color_ID");
    log.fine("AD_Color_ID=" + AD_Color_ID);
    CompiereColor cc = null;
    //  Color Type
    String ColorType = (String) m_mTab.getValue("ColorType");
    if (ColorType == null) {
        log.fine("No ColorType");
        return null;
    }
    //
    if (ColorType.equals(CompiereColor.TYPE_FLAT)) {
        cc = new CompiereColor(getColor(true), true);
    } else if (ColorType.equals(CompiereColor.TYPE_GRADIENT)) {
        Integer RepeatDistance = (Integer) m_mTab.getValue("RepeatDistance");
        String StartPoint = (String) m_mTab.getValue("StartPoint");
        int repeatDistance = RepeatDistance == null ? 0 : RepeatDistance.intValue();
        int startPoint = StartPoint == null ? 0 : Integer.parseInt(StartPoint);
        cc = new CompiereColor(getColor(true), getColor(false), startPoint, repeatDistance);
    } else if (ColorType.equals(CompiereColor.TYPE_LINES)) {
        BigDecimal LineWidth = (BigDecimal) m_mTab.getValue("LineWidth");
        BigDecimal LineDistance = (BigDecimal) m_mTab.getValue("LineDistance");
        int lineWidth = LineWidth == null ? 0 : LineWidth.intValue();
        int lineDistance = LineDistance == null ? 0 : LineDistance.intValue();
        cc = new CompiereColor(getColor(false), getColor(true), lineWidth, lineDistance);
    } else if (ColorType.equals(CompiereColor.TYPE_TEXTURE)) {
        Integer AD_Image_ID = (Integer) m_mTab.getValue("AD_Image_ID");
        String url = getURL(AD_Image_ID);
        if (url == null)
            return null;
        BigDecimal ImageAlpha = (BigDecimal) m_mTab.getValue("ImageAlpha");
        float compositeAlpha = ImageAlpha == null ? 0.7f : ImageAlpha.floatValue();
        cc = new CompiereColor(url, getColor(true), compositeAlpha);
    } else
        return null;
    log.fine("AdempiereColor=" + cc);
    return cc;
}
Also used : CompiereColor(org.compiere.plaf.CompiereColor) BigDecimal(java.math.BigDecimal)

Example 3 with CompiereColor

use of org.compiere.plaf.CompiereColor in project adempiere by adempiere.

the class VColor method actionPerformed.

//  getURL
/*************************************************************************/
/**
	 *  Action Listener - Open Dialog
	 *  @param e event
	 */
public void actionPerformed(ActionEvent e) {
    //  Show Dialog
    CompiereColor cc = ColorEditor.showDialog((JFrame) Env.getParent(this), m_cc);
    if (cc == null) {
        log.info("VColor.actionPerformed - no color");
        return;
    }
    //	set Button
    setBackgroundColor(cc);
    repaint();
    //  Update Values
    m_mTab.setValue("ColorType", cc.getType());
    if (cc.isFlat()) {
        setColor(cc.getFlatColor(), true);
    } else if (cc.isGradient()) {
        setColor(cc.getGradientUpperColor(), true);
        setColor(cc.getGradientLowerColor(), false);
        m_mTab.setValue("RepeatDistance", new BigDecimal(cc.getGradientRepeatDistance()));
        m_mTab.setValue("StartPoint", String.valueOf(cc.getGradientStartPoint()));
    } else if (cc.isLine()) {
        setColor(cc.getLineBackColor(), true);
        setColor(cc.getLineColor(), false);
        m_mTab.getValue("LineWidth");
        m_mTab.getValue("LineDistance");
    } else if (cc.isTexture()) {
        setColor(cc.getTextureTaintColor(), true);
        //	URL url = cc.getTextureURL();
        //	m_mTab.setValue("AD_Image_ID");
        m_mTab.setValue("ImageAlpha", new BigDecimal(cc.getTextureCompositeAlpha()));
    }
    m_cc = cc;
}
Also used : CompiereColor(org.compiere.plaf.CompiereColor) BigDecimal(java.math.BigDecimal)

Example 4 with CompiereColor

use of org.compiere.plaf.CompiereColor in project adempiere by adempiere.

the class ColorEditor method cmd_type.

//  actionPerformed
/**
	 *  Set Type with default values
	 */
private void cmd_type() {
    ValueNamePair vp = (ValueNamePair) typeField.getSelectedItem();
    if (vp.getValue().equals(CompiereColor.TYPE_FLAT))
        m_cc = new CompiereColor(CompiereColor.TYPE_FLAT);
    else if (vp.getValue().equals(CompiereColor.TYPE_GRADIENT))
        m_cc = new CompiereColor(CompiereColor.TYPE_GRADIENT);
    else if (vp.getValue().equals(CompiereColor.TYPE_TEXTURE))
        m_cc = new CompiereColor(CompiereColor.TYPE_TEXTURE);
    else if (vp.getValue().equals(CompiereColor.TYPE_LINES))
        m_cc = new CompiereColor(CompiereColor.TYPE_LINES);
    setColor(m_cc);
}
Also used : CompiereColor(org.compiere.plaf.CompiereColor) ValueNamePair(org.compiere.util.ValueNamePair)

Example 5 with CompiereColor

use of org.compiere.plaf.CompiereColor in project adempiere by adempiere.

the class APanel method initPanel.

/**************************************************************************
	 *	Dynamic Panel Initialization - either single window or workbench.
	 *  <pre>
	 *  either
	 *  - Workbench tabPanel    (VTabbedPane)
	 *      - Tab               (GridController)
	 *  or
	 *  - Workbench tabPanel    (VTabbedPane)
	 *      - Window            (VTabbedPane)
	 *          - Tab           (GridController)
	 *  </pre>
	 *  tabPanel
	 *  @param AD_Workbench_ID  if > 0 this is a workbench, AD_Window_ID ignored
	 *  @param AD_Window_ID     if not a workbench, Window ID
	 *  @param query			if not a Workbench, Zoom Query - additional SQL where clause
	 *  @return true if Panel is initialized successfully
	 */
public boolean initPanel(int AD_Workbench_ID, int AD_Window_ID, MQuery query) {
    log.info("WB=" + AD_Workbench_ID + ", Win=" + AD_Window_ID + ", Query=" + query);
    this.setName("APanel" + AD_Window_ID);
    //  Single Window
    if (AD_Workbench_ID == 0)
        m_mWorkbench = new GridWorkbench(m_ctx, AD_Window_ID);
    else //  Workbench
    {
        //	m_mWorkbench = new MWorkbench(m_ctx);
        //	if (!m_mWorkbench.initWorkbench (AD_Workbench_ID))
        //	{
        //		log.log(Level.SEVERE, "APanel.initWindow - No Workbench Model");
        //		return false;
        //	}
        //	tabPanel.setWorkbench(true);
        //	tabPanel.addChangeListener(this);
        log.warning("Workbench Not implemented yet [" + this + "]");
        loadError = "Workbench Not implemented yet";
        return false;
    }
    Dimension windowSize = m_mWorkbench.getWindowSize();
    MQuery detailQuery = null;
    /**
		 *  WorkBench Loop
		 */
    for (int wb = 0; wb < m_mWorkbench.getWindowCount(); wb++) {
        //  Get/set WindowNo
        //  Timing: ca. 1.5 sec
        m_curWindowNo = Env.createWindowNo(this);
        m_mWorkbench.setWindowNo(wb, m_curWindowNo);
        //  Set AutoCommit for this Window
        Env.setAutoCommit(m_ctx, m_curWindowNo, Env.isAutoCommit(m_ctx));
        boolean autoNew = Env.isAutoNew(m_ctx);
        Env.setAutoNew(m_ctx, m_curWindowNo, autoNew);
        //  Workbench Window
        VTabbedPane window = null;
        //  just one window
        if (m_mWorkbench.getWindowCount() == 1) {
            window = tabPanel;
            window.setWorkbench(false);
        } else {
            VTabbedPane tp = new VTabbedPane(false);
            window = tp;
        }
        //  Window Init
        window.addChangeListener(this);
        /**
			 *  Init Model
			 */
        int wbType = m_mWorkbench.getWindowType(wb);
        /**
			 *  Window
			 */
        if (wbType == GridWorkbench.TYPE_WINDOW) {
            includedMap = new HashMap<Integer, GridController>(4);
            //
            GridWindowVO wVO = AEnv.getMWindowVO(m_curWindowNo, m_mWorkbench.getWindowID(wb), 0);
            if (wVO == null) {
                log.warning("AccessTableNoView for [" + this + "]");
                loadError = "AccessTableNoView";
                return false;
            }
            //  Timing: ca. 0.3-1 sec
            GridWindow mWindow = new GridWindow(wVO, true);
            //	Set SO/AutoNew for Window
            Env.setContext(m_ctx, m_curWindowNo, "IsSOTrx", mWindow.isSOTrx());
            if (!autoNew && mWindow.isTransaction())
                Env.setAutoNew(m_ctx, m_curWindowNo, true);
            m_mWorkbench.setMWindow(wb, mWindow);
            if (wb == 0)
                //	default = only current
                m_onlyCurrentRows = mWindow.isTransaction();
            if (windowSize == null)
                windowSize = mWindow.getWindowSize();
            /**
				 *  Window Tabs
				 */
            int tabSize = mWindow.getTabCount();
            //	Zoom Query
            boolean goSingleRow = query != null;
            for (int tab = 0; tab < tabSize; tab++) {
                boolean included = false;
                //  MTab
                if (tab == 0)
                    mWindow.initTab(0);
                GridTab gTab = mWindow.getTab(tab);
                Env.setContext(m_ctx, m_curWindowNo, tab, GridTab.CTX_TabLevel, Integer.toString(gTab.getTabLevel()));
                //  Query first tab
                if (tab == 0) {
                    //  initial user query for single workbench tab
                    if (m_mWorkbench.getWindowCount() == 1) {
                        if (query != null && query.getZoomTableName() != null && query.getZoomColumnName() != null && query.getZoomValue() instanceof Integer && (Integer) query.getZoomValue() > 0) {
                            if (!query.getZoomTableName().equalsIgnoreCase(gTab.getTableName())) {
                                detailQuery = query;
                                query = new MQuery();
                                query.addRestriction("1=2");
                            }
                        }
                        //Goodwill
                        isCancel = false;
                        query = initialQuery(query, gTab);
                        if (isCancel)
                            //Cancel opening window
                            return false;
                        if (query != null && query.getRecordCount() <= 1)
                            goSingleRow = true;
                    } else if (wb != 0) //  workbench dynamic query for dependent windows
                    {
                        query = m_mWorkbench.getQuery();
                    }
                    //	Set initial Query on first tab
                    if (query != null) {
                        //  Query might involve history
                        m_onlyCurrentRows = false;
                        gTab.setQuery(query);
                    }
                    if (wb == 0)
                        m_curTab = gTab;
                }
                //	query on first tab
                Component tabElement = null;
                //  GridController
                if (gTab.isSortTab()) {
                    VSortTab st = new VSortTab(m_curWindowNo, gTab.getAD_Table_ID(), gTab.getAD_ColumnSortOrder_ID(), gTab.getAD_ColumnSortYesNo_ID());
                    st.setTabLevel(gTab.getTabLevel());
                    tabElement = st;
                } else //	normal tab
                {
                    //  Timing: ca. .1 sec
                    GridController gc = new GridController();
                    CompiereColor cc = mWindow.getColor();
                    if (cc != null)
                        //  set color on Window level
                        gc.setBackgroundColor(cc);
                    //  will set color on Tab level
                    gc.initGrid(gTab, false, m_curWindowNo, this, mWindow, (tab != 0));
                    //  Timing: ca. 6-7 sec for first .2 for next
                    gc.addDataStatusListener(this);
                    //  register Escape Key
                    gc.registerESCAction(aIgnore);
                    //	Set First Tab
                    if (wb == 0 && tab == 0) {
                        m_curGC = gc;
                        //  Screen Sizing
                        Dimension size = gc.getPreferredSize();
                        size.width += 4;
                        size.height += 4;
                        gc.setPreferredSize(size);
                    }
                    tabElement = gc;
                    //	If we have a zoom query, switch to single row
                    if (tab == 0 && goSingleRow)
                        gc.switchSingleRow();
                    // FR [ 1757088 ]
                    GridField[] fields = gc.getMTab().getFields();
                    int m_tab_id = 0;
                    for (int f = 0; f < fields.length; f++) {
                        m_tab_id = fields[f].getIncluded_Tab_ID();
                        if (m_tab_id != 0) {
                            includedMap.put(m_tab_id, gc);
                        }
                    }
                    //	Is this tab included?
                    if (includedMap.size() > 0) {
                        GridController parent = (GridController) includedMap.get(new Integer(gTab.getAD_Tab_ID()));
                        if (parent != null) {
                            // FR [ 1757088 ]
                            gc.removeDataStatusListener(this);
                            GridSynchronizer synchronizer = new GridSynchronizer(mWindow, parent, gc);
                            if (parent == m_curGC)
                                synchronizer.activateChild();
                            included = parent.includeTab(gc, this, synchronizer);
                        }
                    }
                    initSwitchLineAction();
                }
                if (//  Add to TabbedPane
                !included) {
                    StringBuffer tabName = new StringBuffer();
                    tabName.append("<html>");
                    if (gTab.isReadOnly())
                        tabName.append("<i>");
                    int pos = gTab.getName().indexOf(" ");
                    if (pos == -1)
                        tabName.append(gTab.getName()).append("<br>&nbsp;");
                    else {
                        tabName.append(gTab.getName().substring(0, pos)).append("<br>").append(gTab.getName().substring(pos + 1));
                    }
                    if (gTab.isReadOnly())
                        tabName.append("</i>");
                    tabName.append("</html>");
                    //	Add Tab - sets ALT-<number> and Shift-ALT-<x>
                    window.addTab(tabName.toString(), gTab, tabElement);
                }
            }
        //  Tab Loop
        //  Tab background
        //	window.setBackgroundColor(new AdempiereColor(Color.magenta, Color.green));
        }
        //  Single Workbench Window Tab
        if (m_mWorkbench.getWindowCount() == 1) {
            window.setToolTipText(m_mWorkbench.getDescription(wb));
        } else //  Add Workbench Window Tab
        {
            tabPanel.addTab(m_mWorkbench.getName(wb), m_mWorkbench.getIcon(wb), window, m_mWorkbench.getDescription(wb));
        }
        //  Used for Env.getHeader
        Env.setContext(m_ctx, m_curWindowNo, "WindowName", m_mWorkbench.getName(wb));
    }
    //  Workbench Loop
    //  stateChanged (<->) triggered
    toolBar.setName(getTitle());
    m_curTab.getTableModel().setChanged(false);
    //	Set Detail Button
    aDetail.setEnabled(0 != m_curWinTab.getTabCount() - 1);
    //	Enable/Disable Tabs dynamically
    if (m_curWinTab instanceof VTabbedPane)
        ((VTabbedPane) m_curWinTab).evaluate(null);
    //	Size
    if (windowSize != null)
        setPreferredSize(windowSize);
    else
        revalidate();
    if (detailQuery != null && zoomToDetailTab(detailQuery)) {
        return true;
    }
    Dimension size = getPreferredSize();
    log.info("fini - " + size);
    m_curWinTab.requestFocusInWindow();
    return true;
}
Also used : GridWindow(org.compiere.model.GridWindow) MQuery(org.compiere.model.MQuery) Dimension(java.awt.Dimension) GridField(org.compiere.model.GridField) Point(java.awt.Point) VSortTab(org.compiere.grid.VSortTab) GridTab(org.compiere.model.GridTab) GridSynchronizer(org.compiere.grid.GridSynchronizer) GridWindowVO(org.compiere.model.GridWindowVO) CompiereColor(org.compiere.plaf.CompiereColor) VTabbedPane(org.compiere.grid.VTabbedPane) GridWorkbench(org.compiere.model.GridWorkbench) GridController(org.compiere.grid.GridController) Component(java.awt.Component)

Aggregations

CompiereColor (org.compiere.plaf.CompiereColor)11 BigDecimal (java.math.BigDecimal)3 Component (java.awt.Component)1 Dimension (java.awt.Dimension)1 Point (java.awt.Point)1 GridController (org.compiere.grid.GridController)1 GridSynchronizer (org.compiere.grid.GridSynchronizer)1 VSortTab (org.compiere.grid.VSortTab)1 VTabbedPane (org.compiere.grid.VTabbedPane)1 GridField (org.compiere.model.GridField)1 GridTab (org.compiere.model.GridTab)1 GridWindow (org.compiere.model.GridWindow)1 GridWindowVO (org.compiere.model.GridWindowVO)1 GridWorkbench (org.compiere.model.GridWorkbench)1 MColor (org.compiere.model.MColor)1 MQuery (org.compiere.model.MQuery)1 ValueNamePair (org.compiere.util.ValueNamePair)1