@Override public boolean overwrite(File destFile) { return VDialog.showConfirmDialog( canvas, "Overwrite file?", "<html><div align=center>Shall the file " + Message.EMPHASIZE_BEGIN + destFile + Message.EMPHASIZE_END + " be overwritten?.</div></html>", VDialog.DialogType.YES_NO) == VDialog.YES; }
public static void showVersionDialog(final VisualCanvas canvas, Point loc) { // if canvas is inactive don't show dialog if (!canvas.isActive()) { return; } VParamUtil.throwIfNull(canvas); if (dialog != null) { dialog.close(); dialog = null; } moved = false; final VersionManagementPanel componentPanel = new VersionManagementPanel(canvas); dialog = VDialog.showDialogWindow( canvas, "Manage Versions", new VDialogContent(new ResizableContainer(componentPanel)), new String[0]); if (loc != null) { dialog.setLocation(loc); } dialog.addCloseIcon(); dialog.setResizable(false); dialog.setMovable(true); dialog.setActivatable(true); dialog.getStyle().getBaseValues().set(CanvasWindow.FADE_IN_DURATION_KEY, 0.0); dialog.getStyle().getBaseValues().set(CanvasWindow.FADE_OUT_DURATION_KEY, 0.0); dialog.setLayoutController( new VLayoutController() { @Override public void layoutComponent(JComponent c) { try { CanvasWindow w = (CanvasWindow) c; Point loc = w.getLocation(); if (!moved) { Dimension size = w.getSize(); loc.x = (int) (w.getMainCanvas().getVisibleRect().x + w.getMainCanvas().getVisibleRect().getWidth() / 2 - size.width / 2); loc.y = 15 - w.getInsets().top; // - size.height / 2; // check that windows are always inside canvas bounds loc.x = Math.max(loc.x, w.getMainCanvas().getVisibleRect().x); loc.y = Math.max(loc.y, w.getMainCanvas().getVisibleRect().y - w.getInsets().top + 15); loc.x = Math.min( loc.x, w.getMainCanvas().getVisibleRect().x + w.getMainCanvas().getVisibleRect().width - w.getWidth()); loc.y = Math.min( loc.y, w.getMainCanvas().getVisibleRect().y + w.getMainCanvas().getVisibleRect().height - w.getHeight()); } w.setLocation(loc); w.resetWindowLocation(); } catch (Exception ex) { ex.printStackTrace(System.err); } } }); dialog.addActionListener( new CanvasActionListener() { @Override public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals(CanvasWindow.CLOSED_ACTION)) { dialog = null; } if (e.getActionCommand().equals(CanvasWindow.MOVE_ACTION)) { moved = true; } if (e.getActionCommand().equals(CanvasWindow.VISIBLE_ACTION)) { VSwingUtil.invokeLater( new Runnable() { @Override public void run() { componentPanel.requestFocus(); } }); } } }); }