use of java.awt.Dimension in project intellij-community by JetBrains.
the class ResizeProcessor method processMouseEvent.
protected void processMouseEvent(final MouseEvent e) {
if (e.getID() == MouseEvent.MOUSE_PRESSED) {
myLastPoint = e.getPoint();
myBounds = myOriginalParent.getLayoutManager().isGrid() ? myResizedCopy.getBounds() : myComponent.getBounds();
myOriginalBounds = new Rectangle(myBounds);
} else if (e.getID() == MouseEvent.MOUSE_DRAGGED) {
final int dx = e.getX() - myLastPoint.x;
final int dy = e.getY() - myLastPoint.y;
if (myOriginalParent.getLayoutManager().isGrid()) {
final Point point = SwingUtilities.convertPoint(myEditor.getDragLayer(), e.getX(), e.getY(), myOriginalParent.getDelegee());
putGridSpanFeedback(point);
} else if (myOriginalParent.isXY()) {
myEditor.getActiveDecorationLayer().removeFeedback();
setCursor(getResizeCursor());
} else {
return;
}
final GridConstraints constraints = myComponent.getConstraints();
if ((myResizeMask & Painter.WEST_MASK) != 0) {
myBounds.x += dx;
myBounds.width -= dx;
}
if ((myResizeMask & Painter.EAST_MASK) != 0) {
myBounds.width += dx;
}
if ((myResizeMask & Painter.NORTH_MASK) != 0) {
myBounds.y += dy;
myBounds.height -= dy;
}
if ((myResizeMask & Painter.SOUTH_MASK) != 0) {
myBounds.height += dy;
}
final Dimension minSize = myComponent.getMinimumSize();
final Rectangle newBounds = myOriginalParent.getLayoutManager().isGrid() ? myResizedCopy.getBounds() : myComponent.getBounds();
// Component's bounds cannot be less the some minimum size
if (myBounds.width >= minSize.width) {
newBounds.x = myBounds.x;
newBounds.width = myBounds.width;
} else {
if ((myResizeMask & Painter.WEST_MASK) != 0) {
newBounds.x = newBounds.x + newBounds.width - minSize.width;
newBounds.width = minSize.width;
} else if ((myResizeMask & Painter.EAST_MASK) != 0) {
newBounds.width = minSize.width;
}
}
if (myBounds.height >= minSize.height) {
newBounds.y = myBounds.y;
newBounds.height = myBounds.height;
} else {
if ((myResizeMask & Painter.NORTH_MASK) != 0) {
newBounds.y = newBounds.y + newBounds.height - minSize.height;
newBounds.height = minSize.height;
} else if ((myResizeMask & Painter.SOUTH_MASK) != 0) {
newBounds.height = minSize.height;
}
}
final Dimension size = newBounds.getSize();
Util.adjustSize(myComponent.getDelegee(), constraints, size);
newBounds.width = size.width;
newBounds.height = size.height;
if (myOriginalParent.getLayoutManager().isGrid()) {
myResizedCopy.setBounds(newBounds);
} else {
if (myEditor.ensureEditable()) {
myComponent.setBounds(newBounds);
}
}
myEditor.refresh();
myLastPoint = e.getPoint();
} else if (e.getID() == MouseEvent.MOUSE_RELEASED) {
boolean modified = false;
myComponent.getDelegee().setVisible(true);
myComponent.setResizing(false);
myComponent.setSelected(true);
if (myResizedCopy != null) {
myEditor.getDragLayer().remove(myResizedCopy.getDelegee());
}
if (myOriginalParent.getLayoutManager().isGrid() && myEditor.ensureEditable()) {
final Point point = SwingUtilities.convertPoint(myEditor.getDragLayer(), e.getX(), e.getY(), myOriginalParent.getDelegee());
Rectangle rcGrid = getGridSpanGridRect(myOriginalParent, myOriginalConstraints, point, myResizeMask);
if (rcGrid != null && isGridSpanDropAllowed(rcGrid)) {
GridConstraints oldConstraints = (GridConstraints) myOriginalConstraints.clone();
myOriginalConstraints.setColumn(rcGrid.x);
myOriginalConstraints.setRow(rcGrid.y);
myOriginalConstraints.setColSpan(rcGrid.width);
myOriginalConstraints.setRowSpan(rcGrid.height);
myComponent.fireConstraintsChanged(oldConstraints);
modified = true;
}
} else {
modified = true;
}
myEditor.getActiveDecorationLayer().removeFeedback();
myComponent.setDragging(false);
if (modified) {
if (myEditor.ensureEditable()) {
myEditor.refreshAndSave(true);
}
}
}
}
use of java.awt.Dimension in project intellij-community by JetBrains.
the class RadComponent method revalidate.
public final void revalidate() {
RadContainer theContainer = null;
for (RadContainer container = this instanceof RadContainer ? (RadContainer) this : getParent(); container != null; container = container.getParent()) {
final RadContainer parent = container.getParent();
if (parent != null && parent.isXY()) {
final Dimension size = container.getSize();
final Dimension minimumSize = container.getMinimumSize();
if (size.width < minimumSize.width || size.height < minimumSize.height) {
theContainer = container;
}
}
}
if (theContainer != null) {
final Dimension minimumSize = theContainer.getMinimumSize();
minimumSize.width = Math.max(minimumSize.width, theContainer.getWidth());
minimumSize.height = Math.max(minimumSize.height, theContainer.getHeight());
theContainer.getDelegee().setSize(minimumSize);
}
myDelegee.revalidate();
}
use of java.awt.Dimension in project ACS by ACS-Community.
the class CernSysPanel method initialize.
/**
* Init the GUI
*
*/
private void initialize(UndocAlarmTableModel undocModel) {
setLayout(new BorderLayout());
// Build GUI objects
model = new AlarmTableModel(this, ACTIVATE_RDUCTION_RULES, false, undocModel);
model.start();
alarmSound = new AlarmSound(model);
statusLine = new StatusLine(model, this);
alarmTable = new AlarmTable(model, this, undocModel, statusLine);
connectionListener = statusLine;
model.setConnectionListener(statusLine);
detailTable = new AlarmDetailTable();
// The table of alarms
tableScrollPane.setViewportView(alarmTable);
Dimension minimumSize = new Dimension(300, 150);
tableScrollPane.setMinimumSize(minimumSize);
tableScrollPane.setPreferredSize(minimumSize);
// The details table
detailsScrollPane.setViewportView(detailTable);
// The panel with the details
JPanel detailsPanel = new JPanel();
BoxLayout layout = new BoxLayout(detailsPanel, BoxLayout.Y_AXIS);
detailsPanel.setLayout(new BorderLayout());
JPanel lblPnl = new JPanel(new FlowLayout(FlowLayout.CENTER));
lblPnl.add(new JLabel("Alarm details"));
detailsPanel.add(lblPnl, BorderLayout.PAGE_START);
detailsPanel.add(detailsScrollPane, BorderLayout.CENTER);
minimumSize = new Dimension(120, 150);
detailsPanel.setMinimumSize(minimumSize);
detailsPanel.setPreferredSize(minimumSize);
splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, tableScrollPane, detailsPanel);
splitPane.setOneTouchExpandable(true);
splitPane.setResizeWeight(1);
//splitPane.setDividerLocation(tableScrollPane.getMinimumSize().width);
add(splitPane, BorderLayout.CENTER);
// Add the toolbar
toolbar = new Toolbar(alarmTable, model, alarmSound, ACTIVATE_RDUCTION_RULES, this);
add(toolbar, BorderLayout.NORTH);
// Add the status line
add(statusLine, BorderLayout.SOUTH);
// Set the initial auto ack level.
toolbar.setAutoAckLevel(getInitialAutoAckLevel());
}
use of java.awt.Dimension in project ACS by ACS-Community.
the class ScriptFilter method getAddSampleButton.
/**
* This method initializes addSampleButton
* @return javax.swing.JButton
*/
private JButton getAddSampleButton() {
if (addSampleButton == null) {
addSampleButton = new JButton();
addSampleButton.setPreferredSize(new Dimension(120, 24));
addSampleButton.setText("Add Sample");
addSampleButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
if (groupTextField.getText().trim().equalsIgnoreCase(""))
return;
String component = ComponentComboBox.getSelectedItem().toString();
String property = PropertyComboBox.getSelectedItem().toString();
String group = groupTextField.getText();
addToSampling(component, property, group);
}
});
}
return addSampleButton;
}
use of java.awt.Dimension in project ACS by ACS-Community.
the class QueryDlg method initGUI.
/**
* Build the GUI
*
*/
private void initGUI() {
// The actual time/date used to fill the time fields
Calendar calendar = Calendar.getInstance();
guiSwitches = new LoadSwitchesPanel(loggingClient);
JRootPane mainPnl = this.getRootPane();
mainPnl.setLayout(new BorderLayout());
// The panel with the option of the query
JPanel optionsPnl = new JPanel();
GridBagLayout prefsLayout = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
optionsPnl.setLayout(prefsLayout);
// Add all the labels
JLabel maxLogs = new JLabel("Max num of logs to load:");
c.gridx = 0;
c.gridy = 0;
c.anchor = GridBagConstraints.LAST_LINE_START;
c.insets = new Insets(10, 5, 5, 5);
optionsPnl.add(maxLogs, c);
JLabel fromLbl = new JLabel("From:");
c.gridx = 0;
c.gridy = 1;
c.anchor = GridBagConstraints.LAST_LINE_START;
c.insets = new Insets(5, 5, 5, 5);
optionsPnl.add(fromLbl, c);
JLabel toLbl = new JLabel("To:");
c.gridx = 0;
c.gridy = 2;
c.anchor = GridBagConstraints.LAST_LINE_START;
c.insets = new Insets(5, 5, 5, 5);
optionsPnl.add(toLbl, c);
JLabel routinNameLbl = new JLabel("Routine name:");
c.gridx = 0;
c.gridy = 3;
c.anchor = GridBagConstraints.LAST_LINE_START;
c.insets = new Insets(5, 5, 5, 5);
optionsPnl.add(routinNameLbl, c);
JLabel procNameLbl = new JLabel("Process name:");
c.gridx = 0;
c.gridy = 4;
c.anchor = GridBagConstraints.LAST_LINE_START;
c.insets = new Insets(5, 5, 5, 5);
optionsPnl.add(procNameLbl, c);
JLabel srcNameLbl = new JLabel("Source object:");
c.gridx = 0;
c.gridy = 5;
c.anchor = GridBagConstraints.LAST_LINE_START;
c.insets = new Insets(5, 5, 5, 5);
optionsPnl.add(srcNameLbl, c);
JLabel minLogType = new JLabel("From type:");
c.gridx = 0;
c.gridy = 6;
c.anchor = GridBagConstraints.LAST_LINE_START;
c.insets = new Insets(5, 5, 5, 5);
optionsPnl.add(minLogType, c);
JLabel maxLogType = new JLabel("To type:");
c.gridx = 0;
c.gridy = 7;
c.anchor = GridBagConstraints.LAST_LINE_START;
c.insets = new Insets(5, 5, 10, 5);
optionsPnl.add(maxLogType, c);
// Add the input widgets
fromYY = new JTextField(Integer.toString(calendar.get(Calendar.YEAR)), 4);
fromYY.setName(fromLbl.getText());
c.gridx = 1;
c.gridy = 1;
c.anchor = GridBagConstraints.LAST_LINE_START;
c.insets = new Insets(5, 5, 5, 0);
fromYY.getDocument().addDocumentListener(new IntegerDocumentListener());
optionsPnl.add(fromYY, c);
JLabel separatorF1 = new JLabel("-");
c.gridx = 2;
c.gridy = 1;
c.anchor = GridBagConstraints.LAST_LINE_START;
c.insets = new Insets(5, 0, 5, 0);
optionsPnl.add(separatorF1, c);
fromMM = new JTextField(Integer.toString(calendar.get(Calendar.MONTH) + 1), 2);
fromMM.setName(fromLbl.getText());
c.gridx = 3;
c.gridy = 1;
c.anchor = GridBagConstraints.LAST_LINE_START;
fromMM.getDocument().addDocumentListener(new IntegerDocumentListener());
optionsPnl.add(fromMM, c);
JLabel separatorF2 = new JLabel("-");
c.gridx = 4;
c.gridy = 1;
c.anchor = GridBagConstraints.LAST_LINE_START;
optionsPnl.add(separatorF2, c);
fromDD = new JTextField(Integer.toString(calendar.get(Calendar.DAY_OF_MONTH)), 2);
fromDD.setName(fromLbl.getText());
c.gridx = 5;
c.gridy = 1;
c.anchor = GridBagConstraints.LAST_LINE_START;
fromDD.getDocument().addDocumentListener(new IntegerDocumentListener());
optionsPnl.add(fromDD, c);
JLabel tlbl = new JLabel("T");
c.gridx = 6;
c.gridy = 1;
c.anchor = GridBagConstraints.LAST_LINE_START;
optionsPnl.add(tlbl, c);
fromHr = new JTextField(Integer.toString(calendar.get(Calendar.HOUR_OF_DAY)), 2);
fromHr.setName(fromLbl.getText());
c.gridx = 7;
c.gridy = 1;
c.anchor = GridBagConstraints.LAST_LINE_START;
fromHr.getDocument().addDocumentListener(new IntegerDocumentListener());
optionsPnl.add(fromHr, c);
JLabel comaF1Lbl = new JLabel(":");
c.gridx = 8;
c.gridy = 1;
c.anchor = GridBagConstraints.LAST_LINE_START;
optionsPnl.add(comaF1Lbl, c);
fromMin = new JTextField(Integer.toString(calendar.get(Calendar.MINUTE)), 2);
fromMin.setName(fromLbl.getText());
c.gridx = 9;
c.gridy = 1;
c.anchor = GridBagConstraints.LAST_LINE_START;
fromMin.getDocument().addDocumentListener(new IntegerDocumentListener());
optionsPnl.add(fromMin, c);
JLabel comaF2Lbl = new JLabel(":");
c.gridx = 10;
c.gridy = 1;
c.anchor = GridBagConstraints.LAST_LINE_START;
optionsPnl.add(comaF2Lbl, c);
fromSec = new JTextField(Integer.toString(calendar.get(Calendar.SECOND)), 2);
fromSec.setName(fromLbl.getText());
c.gridx = 11;
c.gridy = 1;
c.anchor = GridBagConstraints.LAST_LINE_START;
c.gridwidth = GridBagConstraints.REMAINDER;
fromSec.getDocument().addDocumentListener(new IntegerDocumentListener());
optionsPnl.add(fromSec, c);
toYY = new JTextField(Integer.toString(calendar.get(Calendar.YEAR)), 4);
toYY.setName(toLbl.getText());
c.gridx = 1;
c.gridy = 2;
c.anchor = GridBagConstraints.LAST_LINE_START;
c.insets = new Insets(5, 5, 5, 0);
toYY.getDocument().addDocumentListener(new IntegerDocumentListener());
optionsPnl.add(toYY, c);
JLabel separatorTo1 = new JLabel("-");
c.gridx = 2;
c.gridy = 2;
c.gridwidth = GridBagConstraints.RELATIVE;
c.anchor = GridBagConstraints.LAST_LINE_START;
c.insets = new Insets(5, 0, 5, 0);
optionsPnl.add(separatorTo1, c);
toMM = new JTextField(Integer.toString(calendar.get(Calendar.MONTH) + 1), 2);
toMM.setName(toLbl.getText());
c.gridx = 3;
c.gridy = 2;
c.gridwidth = GridBagConstraints.RELATIVE;
c.anchor = GridBagConstraints.LAST_LINE_START;
toMM.getDocument().addDocumentListener(new IntegerDocumentListener());
optionsPnl.add(toMM, c);
JLabel separatorTo2 = new JLabel("-");
c.gridx = 4;
c.gridy = 2;
c.gridwidth = GridBagConstraints.RELATIVE;
c.anchor = GridBagConstraints.LAST_LINE_START;
optionsPnl.add(separatorTo2, c);
toDD = new JTextField(Integer.toString(calendar.get(Calendar.DAY_OF_MONTH)), 2);
toDD.setName(toLbl.getText());
c.gridx = 5;
c.gridy = 2;
c.gridwidth = GridBagConstraints.RELATIVE;
c.anchor = GridBagConstraints.LAST_LINE_START;
toDD.getDocument().addDocumentListener(new IntegerDocumentListener());
optionsPnl.add(toDD, c);
JLabel t2lbl = new JLabel("T");
c.gridx = 6;
c.gridy = 2;
c.gridwidth = GridBagConstraints.RELATIVE;
c.anchor = GridBagConstraints.LAST_LINE_START;
optionsPnl.add(t2lbl, c);
toHr = new JTextField(Integer.toString(calendar.get(Calendar.HOUR_OF_DAY)), 2);
toHr.setName(toLbl.getText());
c.gridx = 7;
c.gridy = 2;
c.gridwidth = GridBagConstraints.RELATIVE;
c.anchor = GridBagConstraints.LAST_LINE_START;
toHr.getDocument().addDocumentListener(new IntegerDocumentListener());
optionsPnl.add(toHr, c);
JLabel comaTo1Lbl = new JLabel(":");
c.gridx = 8;
c.gridy = 2;
c.gridwidth = GridBagConstraints.RELATIVE;
c.anchor = GridBagConstraints.LAST_LINE_START;
optionsPnl.add(comaTo1Lbl, c);
toMin = new JTextField(Integer.toString(calendar.get(Calendar.MINUTE)), 2);
toMin.setName(toLbl.getText());
c.gridx = 9;
c.gridy = 2;
c.gridwidth = GridBagConstraints.RELATIVE;
c.anchor = GridBagConstraints.LAST_LINE_START;
toMin.getDocument().addDocumentListener(new IntegerDocumentListener());
optionsPnl.add(toMin, c);
JLabel comaTo2Lbl = new JLabel(":");
c.gridx = 10;
c.gridy = 2;
c.gridwidth = GridBagConstraints.RELATIVE;
c.anchor = GridBagConstraints.LAST_LINE_START;
optionsPnl.add(comaTo2Lbl, c);
toSec = new JTextField(Integer.toString(calendar.get(Calendar.SECOND)), 2);
toSec.setName(toLbl.getText());
c.gridx = 11;
c.gridy = 2;
c.anchor = GridBagConstraints.LAST_LINE_START;
c.gridwidth = GridBagConstraints.REMAINDER;
toSec.getDocument().addDocumentListener(new IntegerDocumentListener());
optionsPnl.add(toSec, c);
rowLimit = new JTextField("10000", 20);
rowLimit.setName(maxLogs.getText());
rowLimit.setToolTipText("Valid range is [0, " + (Integer.MAX_VALUE - 1) + "]");
rowLimit.getDocument().addDocumentListener(new IntegerDocumentListener());
c.gridx = 1;
c.gridy = 0;
c.gridwidth = GridBagConstraints.REMAINDER;
c.insets = new Insets(10, 5, 5, 5);
optionsPnl.add(rowLimit, c);
routineName = new JTextField("*", 20);
c.gridx = 1;
c.gridy = 3;
c.gridwidth = GridBagConstraints.REMAINDER;
c.insets = new Insets(5, 5, 5, 5);
optionsPnl.add(routineName, c);
procName = new JTextField("*", 20);
c.gridx = 1;
c.gridy = 4;
c.gridwidth = GridBagConstraints.REMAINDER;
c.insets = new Insets(5, 5, 5, 5);
optionsPnl.add(procName, c);
sourceName = new JTextField("*", 20);
c.gridx = 1;
c.gridy = 5;
c.gridwidth = GridBagConstraints.REMAINDER;
c.insets = new Insets(5, 5, 5, 5);
optionsPnl.add(sourceName, c);
minLogLevelCB = setupTypeCB(minLogLevelCB);
minLogLevelCB.setSelectedIndex(LogTypeHelper.INFO.ordinal());
c.gridx = 1;
c.gridy = 6;
c.gridwidth = GridBagConstraints.REMAINDER;
c.insets = new Insets(5, 5, 5, 5);
optionsPnl.add(minLogLevelCB, c);
maxLogLevelCB = setupTypeCB(maxLogLevelCB);
maxLogLevelCB.setSelectedIndex(LogTypeHelper.EMERGENCY.ordinal());
c.gridx = 1;
c.gridy = 7;
c.gridwidth = GridBagConstraints.REMAINDER;
c.insets = new Insets(5, 5, 10, 5);
optionsPnl.add(maxLogLevelCB, c);
// Add the OK, CANCEL buttons
JPanel bottomPanel = new JPanel(new BorderLayout());
JPanel btnPnl = new JPanel();
btnPnl.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
BoxLayout boxLayout = new BoxLayout(btnPnl, BoxLayout.LINE_AXIS);
btnPnl.setLayout(boxLayout);
btnPnl.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
submitBtn = new JButton("Submit");
submitBtn.addActionListener(this);
submitBtn.setEnabled(archive.getDBStatus() == DBState.DATABASE_OK);
doneBtn = new JButton("Cancel");
doneBtn.addActionListener(this);
btnPnl.add(submitBtn, BorderLayout.WEST);
btnPnl.add(Box.createRigidArea(new Dimension(10, 0)));
btnPnl.add(doneBtn, BorderLayout.EAST);
btnPnl.add(Box.createRigidArea(new Dimension(10, 0)));
// Set the border and a smaller font for the label
statusLbl.setBorder(BorderFactory.createLoweredBevelBorder());
Font fnt = statusLbl.getFont();
Font newFont = fnt.deriveFont(fnt.getSize() * 2 / 3);
statusLbl.setFont(newFont);
bottomPanel.add(btnPnl, BorderLayout.EAST);
bottomPanel.add(statusLbl, BorderLayout.CENTER);
// Add the subpanels
mainPnl.add(guiSwitches, BorderLayout.NORTH);
mainPnl.add(optionsPnl, BorderLayout.CENTER);
mainPnl.add(bottomPanel, BorderLayout.SOUTH);
}
Aggregations