use of java.awt.Component in project adempiere by adempiere.
the class WFContentPanel method removeAll.
// setWorkflow
/**
* Remove All and their listeners
*/
public void removeAll() {
m_nodes.clear();
m_lines.clear();
Component[] components = getComponents();
for (int i = 0; i < components.length; i++) {
Component component = components[i];
component.removeMouseListener(this);
component.removeMouseMotionListener(this);
}
super.removeAll();
}
use of java.awt.Component in project adempiere by adempiere.
the class CompiereTabbedPaneUI method paintContentBorder.
// paintTabBackground
/**************************************************************************
* Paint Content Border (overwriting BasicTabbedPanelUI)
* Uses Color from actual Tab (not from TabbedPane)
* @param g graphics
* @param tabPlacement tab placement
* @param selectedIndex index
*/
protected void paintContentBorder(Graphics g, int tabPlacement, int selectedIndex) {
// System.out.println("TabContentBorder " );
int width = tabPane.getWidth();
int height = tabPane.getHeight();
Insets insets = tabPane.getInsets();
int x = insets.left;
int y = insets.top;
int w = width - insets.right - insets.left;
int h = height - insets.top - insets.bottom;
switch(tabPlacement) {
case LEFT:
x += calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth);
w -= (x - insets.left);
break;
case RIGHT:
w -= calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth);
break;
case BOTTOM:
h -= calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight);
break;
case TOP:
default:
y += calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight);
h -= (y - insets.top);
}
// Fill region behind content area - basically a border
Component comp = null;
if (selectedIndex != -1)
comp = tabPane.getComponentAt(selectedIndex);
if (comp != null && comp instanceof JComponent) {
JComponent jc = (JComponent) comp;
CompiereColor bg = null;
try {
if (jc != null)
bg = (CompiereColor) jc.getClientProperty(CompiereLookAndFeel.BACKGROUND);
} catch (Exception e) {
System.err.println("AdempiereTabbedPaneUI - ClientProperty: " + e.getMessage());
}
if (bg == null) {
bg = new CompiereColor(jc.getBackground());
jc.putClientProperty(CompiereLookAndFeel.BACKGROUND, bg);
}
bg.paintRect(g, jc, x, y, w, h);
} else // Not a JComponent - paint flat
if (comp != null) {
g.setColor(comp.getBackground());
g.fillRect(x, y, w, h);
}
paintContentBorderTopEdge(g, tabPlacement, selectedIndex, x, y, w, h);
paintContentBorderLeftEdge(g, tabPlacement, selectedIndex, x, y, w, h);
paintContentBorderBottomEdge(g, tabPlacement, selectedIndex, x, y, w, h);
paintContentBorderRightEdge(g, tabPlacement, selectedIndex, x, y, w, h);
}
use of java.awt.Component in project adempiere by adempiere.
the class CTable method packColumn.
// autoSize
public void packColumn(TableColumn column) {
int width = 0;
// Header
TableCellRenderer renderer = column.getHeaderRenderer();
if (renderer == null)
renderer = new DefaultTableCellRenderer();
Component comp = null;
if (renderer != null)
comp = renderer.getTableCellRendererComponent(this, column.getHeaderValue(), false, false, 0, 0);
//
if (comp != null) {
width = comp.getPreferredSize().width;
width = Math.max(width, comp.getWidth());
// Cells
int col = column.getModelIndex();
int maxRow = Math.min(20, getRowCount());
try {
for (int row = 0; row < maxRow; row++) {
renderer = getCellRenderer(row, col);
comp = renderer.getTableCellRendererComponent(this, getValueAt(row, col), false, false, row, col);
if (comp != null) {
int rowWidth = comp.getPreferredSize().width;
width = Math.max(width, rowWidth);
}
}
} catch (Exception e) {
log.log(Level.SEVERE, column.getIdentifier().toString(), e);
}
// Width not greater than 250
width = Math.min(MAXSIZE, width + SLACK);
}
//
column.setPreferredWidth(width);
}
use of java.awt.Component in project adempiere by adempiere.
the class CTable method autoSize.
// stopEditor
/**************************************************************************
* Size Columns.
* @param useColumnIdentifier if false uses plain content -
* otherwise uses Column Identifier to indicate displayed columns
*/
public void autoSize(boolean useColumnIdentifier) {
TableModel model = this.getModel();
int size = model.getColumnCount();
// for all columns
for (int c = 0; c < size; c++) {
TableColumn column = getColumnModel().getColumn(c);
// Not displayed columns
if (useColumnIdentifier && (column.getIdentifier() == null || column.getMaxWidth() == 0 || column.getIdentifier().toString().length() == 0))
continue;
int width = 0;
// Header
TableCellRenderer renderer = column.getHeaderRenderer();
if (renderer == null)
renderer = new DefaultTableCellRenderer();
Component comp = null;
if (renderer != null)
comp = renderer.getTableCellRendererComponent(this, column.getHeaderValue(), false, false, 0, 0);
//
if (comp != null) {
width = comp.getPreferredSize().width;
width = Math.max(width, comp.getWidth());
// Cells
int col = column.getModelIndex();
int maxRow = Math.min(20, getRowCount());
try {
for (int row = 0; row < maxRow; row++) {
renderer = getCellRenderer(row, col);
comp = renderer.getTableCellRendererComponent(this, getValueAt(row, col), false, false, row, col);
if (comp != null) {
int rowWidth = comp.getPreferredSize().width;
width = Math.max(width, rowWidth);
}
}
} catch (Exception e) {
log.log(Level.SEVERE, column.getIdentifier().toString(), e);
}
// Width not greater than 250
width = Math.min(MAXSIZE, width + SLACK);
}
//
column.setPreferredWidth(width);
}
// for all columns
}
use of java.awt.Component in project jmeter by apache.
the class RemoteStart method doAction.
@Override
public void doAction(ActionEvent e) {
String name = ((Component) e.getSource()).getName();
if (name != null) {
name = name.trim();
}
String action = e.getActionCommand();
if (action.equals(ActionNames.REMOTE_STOP)) {
GuiPackage.getInstance().getMainFrame().showStoppingMessage(name);
distributedRunner.stop(Arrays.asList(name));
} else if (action.equals(ActionNames.REMOTE_SHUT)) {
GuiPackage.getInstance().getMainFrame().showStoppingMessage(name);
distributedRunner.shutdown(Arrays.asList(name));
} else if (action.equals(ActionNames.REMOTE_START)) {
popupShouldSave(e);
HashTree testTree = getTestTree();
if (popupCheckExistingFileListener(testTree)) {
distributedRunner.init(Arrays.asList(name), testTree);
distributedRunner.start(Arrays.asList(name));
}
} else if (action.equals(ActionNames.REMOTE_START_ALL)) {
popupShouldSave(e);
HashTree testTree = getTestTree();
if (popupCheckExistingFileListener(testTree)) {
distributedRunner.init(getRemoteHosts(), testTree);
distributedRunner.start();
}
} else if (action.equals(ActionNames.REMOTE_STOP_ALL)) {
distributedRunner.stop(getRemoteHosts());
} else if (action.equals(ActionNames.REMOTE_SHUT_ALL)) {
distributedRunner.shutdown(getRemoteHosts());
} else if (action.equals(ActionNames.REMOTE_EXIT)) {
distributedRunner.exit(Arrays.asList(name));
} else if (action.equals(ActionNames.REMOTE_EXIT_ALL)) {
distributedRunner.exit(getRemoteHosts());
}
}
Aggregations