/* * 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;
privateint pageEnd()
{ int i = pageStart + cols * rows; if (i > listModel.getSize() - 1)
{ return listModel.getSize();
} else
{ return i;
}
}
/** Utility field holding list of ItemListeners. */ privatetransient java.util.ArrayList<XItemListener> m_aItemListenerList; privatevoid setVisible(Object control, boolean visible)
{ final XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, control);
xWindow.setVisible(visible);
}
/** * @param i * @return the String in the list model corresponding to the given image url
*/ private String getObjectFor(int i)
{ int ii = getIndexFor(i); if (listModel.getSize() <= ii)
{ returnnull;
} else
{ return (String)listModel.getElementAt(ii);
}
}
/** * @param i * @return the index in the listModel for the given image index.
*/ privateint getIndexFor(int i)
{ return pageStart + i;
}
/** Registers ItemListener to receive events. * @param listener The listener to register.
*/ publicsynchronizedvoid addItemListener(XItemListener listener)
{ if (m_aItemListenerList == null)
{
m_aItemListenerList = new java.util.ArrayList<XItemListener>();
}
m_aItemListenerList.add(listener);
}
/** Removes ItemListener from the list of listeners. * @param listener The listener to remove.
*/ publicsynchronizedvoid removeItemListener(XItemListener listener)
{ if (m_aItemListenerList != null)
{
m_aItemListenerList.remove(listener);
}
}
/** Notifies all registered listeners about the event. *
*/
@SuppressWarnings("unchecked") privatevoid fireItemSelected()
{
java.util.ArrayList<XItemListener> list; synchronized(this)
{ if (m_aItemListenerList == null)
{ return;
}
list = (java.util.ArrayList<XItemListener>) m_aItemListenerList.clone();
} for (int i = 0; i < list.size(); i++)
{
list.get(i).itemStateChanged(null);
}
}
private Counter(int start_, int end_, int max_)
{
start = start_;
end = end_;
max = max_;
}
}
publicboolean isenabled()
{ return benabled;
}
publicvoid setenabled(boolean b)
{
for (int i = 0; i < m_aButtons.length; i++)
{
UnoDialog2.setEnabled(m_aButtons[i], b);
}
UnoDialog2.setEnabled(lblImageText, b); if (showButtons)
{
UnoDialog2.setEnabled(btnBack, b);
UnoDialog2.setEnabled(btnNext, b);
UnoDialog2.setEnabled(lblCounter, b);
}
benabled = b;
}
/** * refresh on all buttons, the selected button will get state pressed
*/ privatevoid refreshSelection()
{ // reset all buttons to not set for (int i = 0; i < m_aButtons.length; i++)
{ if (m_aButtons[i] != null)
{
XControlModel xModel = (XControlModel)UnoDialog2.getModel(m_aButtons[i]);
PropertySetHelper aHelper = new PropertySetHelper(xModel); if (i == m_nCurrentSelection)
{ finalshort one = 1;
aHelper.setPropertyValueDontThrow(PropertyNames.PROPERTY_STATE, Short.valueOf(one));
} else
{ finalshort zero = 0;
aHelper.setPropertyValueDontThrow(PropertyNames.PROPERTY_STATE, Short.valueOf(zero));
}
}
}
}
/** * implementation of XActionListener * will call if a button from the m_aButtonList is pressed.
*/ publicvoid actionPerformed(com.sun.star.awt.ActionEvent actionEvent)
{
XControlModel xModel = (XControlModel)UnoDialog2.getModel(actionEvent.Source);
PropertySetHelper aHelper = new PropertySetHelper(xModel);
int nState = aHelper.getPropertyValueAsInteger(PropertyNames.PROPERTY_STATE, -1); if (nState == 0)
{ // this will avoid a wrong state, if already pressed.
aHelper.setPropertyValueDontThrow(PropertyNames.PROPERTY_STATE, Short.valueOf((short)1));
}
// check which Button is pressed.
String sControlName = aHelper.getPropertyValueAsString(PropertyNames.PROPERTY_NAME, PropertyNames.EMPTY_STRING); final String sButton = sControlName.substring(7 + m_aControlName.length()); int nButton = Integer.parseInt(sButton);
int index = getIndexFor(nButton); if (index < listModel.getSize())
{
setSelected(index);
}
}
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.15 Sekunden
(vorverarbeitet)
¤
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.