Skip to content

Commit 21fd79c

Browse files
authored
Merge pull request #6929 from bndtools/size_improvements
improve size configuration
2 parents 180596f + 092fcf7 commit 21fd79c

File tree

3 files changed

+52
-18
lines changed

3 files changed

+52
-18
lines changed

bndtools.core/src/bndtools/editor/BndSourceEffectivePage.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
import org.eclipse.swt.widgets.Control;
6464
import org.eclipse.swt.widgets.Display;
6565
import org.eclipse.swt.widgets.Event;
66+
import org.eclipse.swt.widgets.Shell;
6667
import org.eclipse.swt.widgets.Table;
6768
import org.eclipse.swt.widgets.TableColumn;
6869
import org.eclipse.swt.widgets.TableItem;
@@ -557,7 +558,15 @@ private void createCustomToolTipSupport(TableViewer tableViewer, List<CellLabelP
557558
false) {
558559
@Override
559560
protected Composite createToolTipContentArea(Event event, Composite parent) {
561+
// Define tooltip size constants
562+
final int TOOLTIP_WIDTH = 700;
563+
final int TOOLTIP_HEIGHT = 300;
564+
560565
Composite container = new Composite(parent, SWT.NONE);
566+
567+
if (parent instanceof Shell) {
568+
parent.setSize(TOOLTIP_WIDTH, TOOLTIP_HEIGHT);
569+
}
561570
container.setLayout(new GridLayout(1, false));
562571

563572
// unfortunatelly lots of ceremony to
@@ -598,8 +607,8 @@ protected Composite createToolTipContentArea(Event event, Composite parent) {
598607
text.setMargins(5, 5, 5, 5); // left, top, right, bottom
599608

600609
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
601-
gd.widthHint = 350;
602-
gd.heightHint = 200;
610+
gd.widthHint = TOOLTIP_WIDTH - 50; // Account for margins and scrollbars
611+
gd.heightHint = TOOLTIP_HEIGHT - 80; // Account for margins, scrollbars, and toolbar
603612
text.setLayoutData(gd);
604613
text.setText(tooltipText);
605614

bndtools.core/src/bndtools/wizards/newworkspace/NewWorkspaceWizard.java

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import org.eclipse.jface.wizard.WizardPage;
2929
import org.eclipse.swt.SWT;
3030
import org.eclipse.swt.graphics.Image;
31+
import org.eclipse.swt.graphics.Point;
32+
import org.eclipse.swt.graphics.Rectangle;
3133
import org.eclipse.swt.layout.GridData;
3234
import org.eclipse.swt.layout.GridLayout;
3335
import org.eclipse.swt.program.Program;
@@ -36,6 +38,7 @@
3638
import org.eclipse.swt.widgets.DirectoryDialog;
3739
import org.eclipse.swt.widgets.Display;
3840
import org.eclipse.swt.widgets.Label;
41+
import org.eclipse.swt.widgets.Shell;
3942
import org.eclipse.swt.widgets.Table;
4043
import org.eclipse.swt.widgets.Text;
4144
import org.eclipse.ui.IImportWizard;
@@ -62,13 +65,12 @@
6265
*/
6366
public class NewWorkspaceWizard extends Wizard implements IImportWizard, INewWizard {
6467

65-
66-
static final Logger log = LoggerFactory.getLogger(NewWorkspaceWizard.class);
68+
static final Logger log = LoggerFactory.getLogger(NewWorkspaceWizard.class);
6769

6870
final Model model;
6971
final UI<Model> ui;
70-
final NewWorkspaceWizardPage page = new NewWorkspaceWizardPage();
71-
final FragmentTemplateEngine templates;
72+
final NewWorkspaceWizardPage page = new NewWorkspaceWizardPage();
73+
final FragmentTemplateEngine templates;
7274

7375
final static Image verified = Icons.image("icons/tick.png", false);
7476
final static Image verifiedGreyedOut = new Image(Display.getDefault(), verified, SWT.IMAGE_DISABLE);
@@ -124,8 +126,7 @@ public boolean performFinish() {
124126
// show a confirmation dialog
125127
// if there is at least one 3rd-party template selected
126128
long num3rdParty = model.selectedTemplates.stream()
127-
.filter(t -> !t
128-
.isOfficial())
129+
.filter(t -> !t.isOfficial())
129130
.count();
130131

131132
boolean confirmed = num3rdParty == 0 || openConfirm(getShell(), "Install 3rd-Party templates",
@@ -146,7 +147,6 @@ public boolean performFinish() {
146147
} else
147148
return false;
148149

149-
150150
}
151151

152152
class NewWorkspaceWizardPage extends WizardPage {
@@ -244,12 +244,10 @@ public String getText(Object element) {
244244
@Override
245245
public String getText(Object element) {
246246
if (element instanceof TemplateInfo ti) {
247-
if (ti
248-
.isOfficial()) {
247+
if (ti.isOfficial()) {
249248
return "bndtools (Official)";
250249

251-
}
252-
else {
250+
} else {
253251
return ti.id()
254252
.organisation() + " (3rd Party)";
255253
}
@@ -269,9 +267,8 @@ public Image getImage(Object element) {
269267

270268
});
271269

272-
273-
tableLayout.addColumnData(new ColumnWeightData(1, 150, false));
274-
tableLayout.addColumnData(new ColumnWeightData(10, 400, true));
270+
tableLayout.addColumnData(new ColumnWeightData(1, 200, false));
271+
tableLayout.addColumnData(new ColumnWeightData(10, 460, true));
275272
tableLayout.addColumnData(new ColumnWeightData(20, 100, true));
276273

277274
Button addButton = new Button(container, SWT.PUSH);
@@ -308,10 +305,32 @@ public Image getImage(Object element) {
308305
UI.checkbox(browseButton)
309306
.subscribe(this::browseForLocation);
310307

311-
getShell().setSize(840, 480);
308+
centerShell();
312309
ui.update();
313310
}
314311

312+
private void centerShell() {
313+
Shell shell = getShell();
314+
shell.setSize(840, 480);
315+
Shell parent = (Shell) shell.getParent();
316+
if (parent != null) {
317+
Rectangle parentBounds = parent.getBounds();
318+
Point shellSize = shell.getSize();
319+
int x = parentBounds.x + (parentBounds.width - shellSize.x) / 2;
320+
int y = parentBounds.y + (parentBounds.height - shellSize.y) / 2;
321+
shell.setLocation(x, y);
322+
} else {
323+
// If no parent, center on the display
324+
Rectangle displayBounds = shell.getDisplay()
325+
.getPrimaryMonitor()
326+
.getBounds();
327+
Point shellSize = shell.getSize();
328+
int x = (displayBounds.width - shellSize.x) / 2;
329+
int y = (displayBounds.height - shellSize.y) / 2;
330+
shell.setLocation(x, y);
331+
}
332+
}
333+
315334
List<TemplateInfo> toTemplates(Object[] selection) {
316335
return Stream.of(selection)
317336
.map(o -> (TemplateInfo) o)

bndtools.test/workspace/.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ Archive
55
.DS_Store
66
.*.swp
77
/.gradle/
8-
/reports/
8+
/bin/
99
/generated/
10+
/reports/
11+
/install-jdk.sh
1012
.to
13+
.idea
14+
.settings
15+
.flattened-pom.xml
16+
target/

0 commit comments

Comments
 (0)