/* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ package com.sun.star.wizards.ui;
publicvoid removeSelectedItems(XListBox xListBox)
{ short[] SelList = xListBox.getSelectedItemsPos(); int Sellen = SelList.length; for (int i = Sellen - 1; i >= 0; i--)
{
xListBox.removeItems(SelList[i], (short) 1);
}
}
publicstaticint getListBoxItemCount(XListBox _xListBox)
{ // This function may look ugly, but this is the only way to check the count // of values in the model,which is always right. // the control is only a view and could be right or not. final String[] fieldnames = (String[]) Helper.getUnoPropertyValue(getModel(_xListBox), PropertyNames.STRING_ITEM_LIST); return fieldnames.length;
}
/** * The problem with setting the visibility of controls is that changing the current step * of a dialog will automatically make all controls visible. The PropertyNames.PROPERTY_STEP property always wins against * the property "visible". Therefore a control meant to be invisible is placed on a step far far away. * Afterwards the step property of the dialog has to be set with "repaintDialogStep". As the performance * of that method is very bad it should be used only once for all controls * @param controlname the name of the control * @param bIsVisible sets the control visible or invisible
*/ publicvoid setControlVisible(String controlname, boolean bIsVisible)
{ try
{ int iCurDialogStep = AnyConverter.toInt(Helper.getUnoPropertyValue(this.xDialogModel, PropertyNames.PROPERTY_STEP)); if (bIsVisible)
{
setControlProperty(controlname, PropertyNames.PROPERTY_STEP, Integer.valueOf(iCurDialogStep));
} else
{
setControlProperty(controlname, PropertyNames.PROPERTY_STEP, UIConsts.INVISIBLESTEP);
}
} catch (com.sun.star.lang.IllegalArgumentException exception)
{
exception.printStackTrace(System.err);
}
}
publicvoid selectListBoxItem(XListBox xListBox, short iFieldsSelIndex)
{ if (iFieldsSelIndex > -1)
{ int FieldCount = xListBox.getItemCount(); if (FieldCount > 0)
{ if (iFieldsSelIndex < FieldCount)
{
xListBox.selectItemPos(iFieldsSelIndex, true);
} else
{
xListBox.selectItemPos((short) (iFieldsSelIndex - 1), true);
}
}
}
}
/** deselects a Listbox. MultipleMode is not supported
*/ publicstaticvoid deselectListBox(XInterface _xBasisListBox)
{
Object oListBoxModel = getModel(_xBasisListBox);
Object sList = Helper.getUnoPropertyValue(oListBoxModel, PropertyNames.STRING_ITEM_LIST);
Helper.setUnoPropertyValue(oListBoxModel, PropertyNames.STRING_ITEM_LIST, new String[]
{
});
Helper.setUnoPropertyValue(oListBoxModel, PropertyNames.STRING_ITEM_LIST, sList);
}
publicvoid calculateDialogPosition(Rectangle FramePosSize)
{ // TODO: check if it would be useful or possible to create a dialog peer, that can be used for the messageboxes to // maintain modality when they pop up.
Rectangle CurPosSize = xWindow.getPosSize(); int WindowHeight = FramePosSize.Height; int WindowWidth = FramePosSize.Width; int DialogWidth = CurPosSize.Width; int DialogHeight = CurPosSize.Height; int iXPos = ((WindowWidth / 2) - (DialogWidth / 2)); int iYPos = ((WindowHeight / 2) - (DialogHeight / 2));
xWindow.setPosSize(iXPos, iYPos, DialogWidth, DialogHeight, PosSize.POS);
}
/** * * @return 0 for cancel, 1 for ok
*/ publicshort executeDialog(Rectangle FramePosSize) throws com.sun.star.uno.Exception
{ if (xControl.getPeer() == null)
{ thrownew java.lang.IllegalArgumentException("Please create a peer, using your own frame");
}
calculateDialogPosition(FramePosSize); if (xWindowPeer == null)
{
createWindowPeer();
}
xVclWindowPeer = UnoRuntime.queryInterface(XVclWindowPeer.class, xWindowPeer); this.BisHighContrastModeActivated = Boolean.valueOf(this.isHighContrastModeActivated());
xDialog = UnoRuntime.queryInterface(XDialog.class, xUnoDialog); return xDialog.execute();
}
/** * @return 0 for cancel, 1 for ok.
*/ publicshort executeDialog(XInterface xComponent) throws com.sun.star.uno.Exception
{
XFrame frame = UnoRuntime.queryInterface(XFrame.class, xComponent); if (frame != null)
{
XWindow w = frame.getComponentWindow(); if (w != null)
{ return executeDialog(w.getPosSize());
}
}
/** * When possible, use the other executeDialog methods, since * there may be problems retrieving the actual active frame, * for example under linux. * @return 0 for cancel, 1 for ok
*/ publicshort executeDialog() throws com.sun.star.uno.Exception
{ return executeDialog(Desktop.getActiveFrame(xMSF));
}
/** * create a peer for this dialog, using the given peer as a parent.
*/ public XWindowPeer createWindowPeer(XWindowPeer parentPeer) throws com.sun.star.uno.Exception
{
xWindow.setVisible(false);
Object tk = xMSF.createInstance("com.sun.star.awt.Toolkit"); if (parentPeer == null)
{
parentPeer = UnoRuntime.queryInterface(XToolkit.class, tk).getDesktopWindow();
}
XToolkit xToolkit = UnoRuntime.queryInterface(XToolkit.class, tk);
xReschedule = UnoRuntime.queryInterface(XReschedule.class, xToolkit); // TEUER!
xControl.createPeer(xToolkit, parentPeer);
xWindowPeer = xControl.getPeer(); return xControl.getPeer();
}
/** * Creates a peer for this dialog, using the active OO frame as the parent window.
*/ public XWindowPeer createWindowPeer() throws com.sun.star.uno.Exception
{ return createWindowPeer(null);
}
/** * @return the name of the property that contains the value of a controlmodel
*/ publicstatic String getDisplayProperty(Object oControlModel)
{ int itype = getControlModelType(oControlModel); return getDisplayProperty(itype);
}
/** * @param itype The type of the control conforming to UIConst.ControlType * @return the name of the property that contains the value of a controlmodel
*/ privatestatic String getDisplayProperty(int itype)
{ switch (itype)
{ case UIConsts.CONTROLTYPE.FIXEDTEXT: return PropertyNames.PROPERTY_LABEL; case UIConsts.CONTROLTYPE.BUTTON: return PropertyNames.PROPERTY_LABEL; case UIConsts.CONTROLTYPE.FIXEDLINE: return PropertyNames.PROPERTY_LABEL; case UIConsts.CONTROLTYPE.NUMERICFIELD: return"Value"; case UIConsts.CONTROLTYPE.CURRENCYFIELD: return"Value"; case UIConsts.CONTROLTYPE.FORMATTEDFIELD: return"EffectiveValue"; case UIConsts.CONTROLTYPE.DATEFIELD: return"Date"; case UIConsts.CONTROLTYPE.TIMEFIELD: return"Time"; case UIConsts.CONTROLTYPE.SCROLLBAR: return"ScrollValue"; case UIConsts.CONTROLTYPE.PROGRESSBAR: return"ProgressValue"; case UIConsts.CONTROLTYPE.IMAGECONTROL: return PropertyNames.PROPERTY_IMAGEURL; case UIConsts.CONTROLTYPE.RADIOBUTTON: return PropertyNames.PROPERTY_STATE; case UIConsts.CONTROLTYPE.CHECKBOX: return PropertyNames.PROPERTY_STATE; case UIConsts.CONTROLTYPE.EDITCONTROL: return"Text"; case UIConsts.CONTROLTYPE.COMBOBOX: return"Text"; case UIConsts.CONTROLTYPE.PATTERNFIELD: return"Text"; case UIConsts.CONTROLTYPE.LISTBOX: return PropertyNames.SELECTED_ITEMS; default: return PropertyNames.EMPTY_STRING;
}
}
publicvoid addResourceHandler()
{
m_oResource = new Resource(xMSF);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.