You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "neilcsmith-net (via GitHub)" <gi...@apache.org> on 2024/04/04 10:56:53 UTC
[PR] Add Dashboard API and use to provide replacement for Welcome page [netbeans]
neilcsmith-net opened a new pull request, #7239:
URL: https://github.com/apache/netbeans/pull/7239
This PR provides a new, in-development, Dashboard API in the platform, and uses it to provide a replacement for the current Welcome page in the IDE.
A widget is a way of contextually grouping actions, textual information, images and links on a dashboard. A widget is a logical description of these elements (similar perhaps to NotifyDescriptor) - a dashboard displayer handles actual rendering to a UI, providing ability to unify design, or output other than with Swing. Widgets are registered in the layer (`Dashboard/Widgets`) and referenced where used (currently just `Dashboard/Main`). The idea is to allow for future customization similar to how toolbars reference actions, and to allow alternative contextual dashboards, such as perhaps an editor dashboard providing a customizable quick overview of the file in question.
Why an API? Well, initially I was writing this for two platform applications that need to collate and show information from different modules. It overlapped with improvements I think need to be made to the current Welcome page, which looks out of place now, and doesn't "grow" with the user to remain a useful tool. Ideally, widgets get provided by modules in the same way that actions are, rather than all residing within the IDE welcome page replacement. The addition of two friend API here provides evidence of why we might want to do that in future, and means that at the moment, those widgets could not be replicated in a platform application. We might also provide additional widgets that the user can add as they get more experienced.
Post NB22 development should (and will from me) focus on adding customization, layer generating annotations, additional widgets and stabilization. Possibly also an overlay displayer in addition to top component.
I realise this is a somewhat large change close to freeze. I was hoping to get it in a bit earlier, and realise it is likely to require some discussion, additional testing and tweaks. Would love to get it in to NB22 though - I'd still like to use it in those platform applications!
Current dashboard display with light and dark themes -


--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Add Dashboard API and use to provide replacement for Welcome page [netbeans]
Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #7239:
URL: https://github.com/apache/netbeans/pull/7239#discussion_r1558690317
##########
platform/api.dashboard/src/org/netbeans/modules/dashboard/WidgetComponents.java:
##########
@@ -0,0 +1,403 @@
+/*
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.dashboard;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Cursor;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.Image;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.net.URI;
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.BorderFactory;
+import javax.swing.Icon;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JSeparator;
+import javax.swing.JTextArea;
+import javax.swing.UIManager;
+import javax.swing.border.Border;
+import org.netbeans.spi.dashboard.WidgetElement;
+import org.netbeans.spi.dashboard.WidgetElement.ActionElement;
+import org.netbeans.spi.dashboard.WidgetElement.ComponentElement;
+import org.netbeans.spi.dashboard.WidgetElement.ImageElement;
+import org.netbeans.spi.dashboard.WidgetElement.LinkElement;
+import org.netbeans.spi.dashboard.WidgetElement.SeparatorElement;
+import org.netbeans.spi.dashboard.WidgetElement.TextElement;
+import org.openide.awt.HtmlBrowser;
+import org.openide.awt.StatusDisplayer;
+import org.openide.util.Exceptions;
+import org.openide.util.ImageUtilities;
+import org.openide.util.NbBundle;
+
+/**
+ * Default creation of JComponents for WidgetElements.
+ */
+@NbBundle.Messages({
+ "# {0} - link URI",
+ "TXT_statusLink=Open {0}"
+})
+final class WidgetComponents {
+
+ private WidgetComponents() {
+
+ }
+
+ static JComponent titleComponentFor(String title) {
+ MultiLineText text = new MultiLineText(title);
+ Font font = text.getFont();
+ text.setFont(font.deriveFont(font.getSize() * 1.4f));
+ return text;
+ }
+
+ static JComponent componentFor(WidgetElement element) {
+ if (element instanceof TextElement textElement) {
+ return componentForText(textElement);
+ } else if (element instanceof ImageElement imageElement) {
+ return componentForImage(imageElement);
+ } else if (element instanceof ActionElement actionElement) {
+ return componentForAction(actionElement);
+ } else if (element instanceof LinkElement linkElement) {
+ return componentForLink(linkElement);
+ } else if (element instanceof SeparatorElement sepElement) {
+ return componentForSeparator(sepElement);
+ } else if (element instanceof ComponentElement cmpElement) {
+ return cmpElement.component();
+ }
+ return null;
+ }
+
+ private static JComponent componentForText(TextElement element) {
+ MultiLineText text = new MultiLineText(element.text());
+ TextElement.Kind kind = element.kind();
+ if (kind == TextElement.Kind.SUBHEADING) {
+ Font font = text.getFont();
+ text.setFont(font.deriveFont(font.getSize() * 1.1f));
+ } else if (kind == TextElement.Kind.ASIDE || kind == TextElement.Kind.UNAVAILABLE) {
+ Font font = text.getFont();
+ text.setFont(font.deriveFont(font.getSize() * 0.9f));
+ Color color = UIManager.getColor("controlDkShadow");
+ if (color != null) {
+ text.setForeground(color);
+ }
+ }
+ return text;
+ }
+
+ private static JComponent componentForImage(ImageElement element) {
+ Image image = ImageUtilities.loadImage(element.resourcePath(), true);
+ Icon icon = ImageUtilities.image2Icon(image);
+ JLabel label = new JLabel(icon);
+ label.setMinimumSize(new Dimension(0, 0));
+ return label;
+ }
+
+ private static JComponent componentForAction(ActionElement element) {
+ if (element.asLink()) {
+ return new LinkButton(element.action(), element.showIcon());
+ } else {
+ return new WidgetButton(element.action(), element.showIcon());
+ }
+ }
+
+ private static JComponent componentForLink(LinkElement element) {
+ Action action = new URIOpenAction(element.text(), element.link());
+ if (element.asButton()) {
+ return new WidgetButton(action, false);
+ } else {
+ return new LinkButton(action, false);
+ }
+ }
+
+ private static JComponent componentForSeparator(WidgetElement.SeparatorElement element) {
+ JSeparator sep = new JSeparator();
+ sep.setPreferredSize(new Dimension(75, 8));
+ return sep;
+ }
+
+ private static class MultiLineText extends JTextArea {
+
+ private MultiLineText(String text) {
+ super(text);
+ setEditable(false);
+ setCursor(null);
+ setOpaque(false);
+ // some LAFs (looking at you Nimbus!) require transparent bg color
+ setBackground(new Color(0, 0, 0, 0));
+ setFocusable(false);
+ setBorder(BorderFactory.createEmptyBorder());
+ setMargin(new Insets(0, 0, 0, 0));
+ Font labelFont = UIManager.getFont("Label.font");
+ if (labelFont != null) {
+ setFont(labelFont);
+ }
+ Color labelColor = UIManager.getColor("Label.foreground");
+ if (labelColor != null) {
+ setForeground(labelColor);
+ }
+ setWrapStyleWord(true);
+ setLineWrap(true);
+ }
+
+ }
+
+ private static abstract class AbstractWidgetButton extends JButton {
+
+ private final boolean allowIcon;
+
+ private AbstractWidgetButton(Action action, boolean allowIcon) {
+ super(action);
+ this.allowIcon = allowIcon;
+ if (!allowIcon) {
+ setIcon(null);
+ }
+ setHorizontalAlignment(LEFT);
+ setToolTipText(null);
+ addMouseListener(new MouseAdapter() {
+
+ @Override
+ public void mouseEntered(MouseEvent e) {
+ onMouseEnter();
+ }
+
+ @Override
+ public void mouseExited(MouseEvent e) {
+ onMouseExit();
+ }
+
+ });
+ }
+
+ void onMouseEnter() {
+ Action action = getAction();
+ if (action != null) {
+ Object status = action.getValue(Action.SHORT_DESCRIPTION);
+ if (status instanceof String statusText) {
+ StatusDisplayer.getDefault().setStatusText(statusText);
+ }
+ }
+ }
+
+ void onMouseExit() {
+ StatusDisplayer.getDefault().setStatusText("");
+ }
+
+ @Override
+ protected void actionPropertyChanged(Action action, String propertyName) {
+ if (allowedPropertyChange(propertyName)) {
+ super.actionPropertyChanged(action, propertyName);
+ }
+ }
+
+ private boolean allowedPropertyChange(String propertyName) {
+ return switch (propertyName) {
+ case Action.SMALL_ICON ->
+ allowIcon;
+ case Action.LARGE_ICON_KEY ->
+ allowIcon;
+ case Action.SHORT_DESCRIPTION ->
+ false;
+ case Action.LONG_DESCRIPTION ->
+ false;
+ default ->
+ true;
+ };
Review Comment:
probably going to have to fix the formatter for this one day so that witch statements can be written like:
```java
return switch (propertyName) {
case Action.SMALL_ICON -> allowIcon;
case Action.LARGE_ICON_KEY -> allowIcon;
case Action.SHORT_DESCRIPTION -> false;
case Action.LONG_DESCRIPTION -> false;
default -> true;
};
```
##########
platform/api.dashboard/src/org/netbeans/modules/dashboard/DashboardTopComponent.java:
##########
@@ -0,0 +1,222 @@
+/*
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.dashboard;
+
+import java.util.List;
+import org.netbeans.api.dashboard.DashboardManager;
+import org.netbeans.api.settings.ConvertAsProperties;
+import org.netbeans.spi.dashboard.DashboardDisplayer;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.windows.TopComponent;
+import org.openide.util.NbBundle.Messages;
+import org.openide.windows.OnShowing;
+import org.openide.windows.WindowManager;
+import org.openide.windows.WindowSystemEvent;
+import org.openide.windows.WindowSystemListener;
+
+/**
+ * Default Dashboard Displayer top component.
+ */
+@ConvertAsProperties(
+ dtd = "-//org.netbeans.modules.dashboard//Dashboard//EN",
+ autostore = false
+)
+@TopComponent.Description(
+ preferredID = "DashboardDisplayer",
+ persistenceType = TopComponent.PERSISTENCE_ONLY_OPENED
+)
+@TopComponent.Registration(mode = "editor", openAtStartup = false, position = 0)
+@Messages({
+ "CTL_DashboardTopComponent=Dashboard",
+ "HINT_DashboardTopComponent=The Dashboard window"
+})
+public final class DashboardTopComponent extends TopComponent {
+
+ private static final String ID = "DashboardDisplayer";
+
+ private List<DashboardDisplayer.WidgetReference> widgetRefs;
+ private DashboardPanel dashboardPanel;
+
+ public DashboardTopComponent() {
+ initComponents();
+ scrollPane.getVerticalScrollBar().setUnitIncrement(20);
+ setName(Bundle.CTL_DashboardTopComponent());
+ setToolTipText(Bundle.HINT_DashboardTopComponent());
+ }
+
+ /**
+ * This method is called from within the constructor to initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is always
+ * regenerated by the Form Editor.
+ */
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ scrollPane = new javax.swing.JScrollPane();
+ dashContainer = new javax.swing.JPanel();
+ emptyLabel = new javax.swing.JLabel();
+
+ setLayout(new java.awt.BorderLayout());
+
+ scrollPane.setBorder(null);
+ scrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
+ scrollPane.setViewportBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
+
+ dashContainer.setLayout(new java.awt.GridBagLayout());
+
+ org.openide.awt.Mnemonics.setLocalizedText(emptyLabel, org.openide.util.NbBundle.getMessage(DashboardTopComponent.class, "DashboardTopComponent.emptyLabel.text")); // NOI18N
+ dashContainer.add(emptyLabel, new java.awt.GridBagConstraints());
+
+ scrollPane.setViewportView(dashContainer);
+
+ add(scrollPane, java.awt.BorderLayout.CENTER);
+ }// </editor-fold>//GEN-END:initComponents
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JPanel dashContainer;
+ private javax.swing.JLabel emptyLabel;
+ private javax.swing.JScrollPane scrollPane;
+ // End of variables declaration//GEN-END:variables
+ @Override
+ public void componentShowing() {
+ if (dashboardPanel != null) {
+ dashboardPanel.notifyShowing();
+ }
+ }
+
+ @Override
+ public void componentHidden() {
+ if (dashboardPanel != null) {
+ dashboardPanel.notifyHidden();
+ }
+ }
+
+ void writeProperties(java.util.Properties p) {
+ // better to version settings since initial version as advocated at
+ // http://wiki.apidesign.org/wiki/PropertyFiles
+ p.setProperty("version", "1.0"); //NOI18N
+ // TODO store your settings
+ }
+
+ void readProperties(java.util.Properties p) {
+ String version = p.getProperty("version");
+ // TODO read your settings according to their version
+ }
+
+ private void installWidgets(DefaultDashboardDisplayer displayer,
+ List<DashboardDisplayer.WidgetReference> widgetRefs) {
+ if (this.widgetRefs != null) {
+ if (this.widgetRefs.equals(widgetRefs)) {
+ return;
+ }
+ }
+ this.widgetRefs = List.copyOf(widgetRefs);
+ // TODO allow panel to be reconfigured at runtime, and detach removed widgets
+ this.dashboardPanel = new DashboardPanel(displayer, widgetRefs);
+ dashContainer.removeAll();
+ dashContainer.add(this.dashboardPanel);
+ dashboardPanel.notifyShowing();
+ }
+
+ static void show(DefaultDashboardDisplayer displayer,
+ List<DashboardDisplayer.WidgetReference> widgetRefs) {
+ DashboardTopComponent dashTC = find();
+ if (dashTC == null) {
+ return;
+ }
+ if (widgetRefs.isEmpty()) {
+ dashTC.close();
+ return;
+ }
+ dashTC.installWidgets(displayer, widgetRefs);
+ if (!dashTC.isOpened()) {
+ dashTC.openAtTabPosition(0);
+ }
+ dashTC.requestActive();
+ }
+
+ private static DashboardTopComponent find() {
+ TopComponent tc = WindowManager.getDefault().findTopComponent(ID);
+ if (tc instanceof DashboardTopComponent dashTC) {
+ return dashTC;
+ } else {
+ return null;
+ }
Review Comment:
this made me curious if the new intanceof/cast syntax supports the ternary operator, turns out it does!
```java
return tc instanceof DashboardTopComponent dashTC ? dashTC : null;
```
##########
platform/api.dashboard/src/org/netbeans/modules/dashboard/DashboardTopComponent.java:
##########
@@ -0,0 +1,222 @@
+/*
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.dashboard;
+
+import java.util.List;
+import org.netbeans.api.dashboard.DashboardManager;
+import org.netbeans.api.settings.ConvertAsProperties;
+import org.netbeans.spi.dashboard.DashboardDisplayer;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.windows.TopComponent;
+import org.openide.util.NbBundle.Messages;
+import org.openide.windows.OnShowing;
+import org.openide.windows.WindowManager;
+import org.openide.windows.WindowSystemEvent;
+import org.openide.windows.WindowSystemListener;
+
+/**
+ * Default Dashboard Displayer top component.
+ */
+@ConvertAsProperties(
+ dtd = "-//org.netbeans.modules.dashboard//Dashboard//EN",
+ autostore = false
+)
+@TopComponent.Description(
+ preferredID = "DashboardDisplayer",
+ persistenceType = TopComponent.PERSISTENCE_ONLY_OPENED
+)
+@TopComponent.Registration(mode = "editor", openAtStartup = false, position = 0)
+@Messages({
+ "CTL_DashboardTopComponent=Dashboard",
+ "HINT_DashboardTopComponent=The Dashboard window"
+})
+public final class DashboardTopComponent extends TopComponent {
+
+ private static final String ID = "DashboardDisplayer";
+
+ private List<DashboardDisplayer.WidgetReference> widgetRefs;
+ private DashboardPanel dashboardPanel;
+
+ public DashboardTopComponent() {
+ initComponents();
+ scrollPane.getVerticalScrollBar().setUnitIncrement(20);
+ setName(Bundle.CTL_DashboardTopComponent());
+ setToolTipText(Bundle.HINT_DashboardTopComponent());
+ }
+
+ /**
+ * This method is called from within the constructor to initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is always
+ * regenerated by the Form Editor.
+ */
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ scrollPane = new javax.swing.JScrollPane();
+ dashContainer = new javax.swing.JPanel();
+ emptyLabel = new javax.swing.JLabel();
+
+ setLayout(new java.awt.BorderLayout());
+
+ scrollPane.setBorder(null);
+ scrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
+ scrollPane.setViewportBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
+
+ dashContainer.setLayout(new java.awt.GridBagLayout());
+
+ org.openide.awt.Mnemonics.setLocalizedText(emptyLabel, org.openide.util.NbBundle.getMessage(DashboardTopComponent.class, "DashboardTopComponent.emptyLabel.text")); // NOI18N
+ dashContainer.add(emptyLabel, new java.awt.GridBagConstraints());
+
+ scrollPane.setViewportView(dashContainer);
+
+ add(scrollPane, java.awt.BorderLayout.CENTER);
+ }// </editor-fold>//GEN-END:initComponents
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JPanel dashContainer;
+ private javax.swing.JLabel emptyLabel;
+ private javax.swing.JScrollPane scrollPane;
+ // End of variables declaration//GEN-END:variables
+ @Override
+ public void componentShowing() {
+ if (dashboardPanel != null) {
+ dashboardPanel.notifyShowing();
+ }
+ }
+
+ @Override
+ public void componentHidden() {
+ if (dashboardPanel != null) {
+ dashboardPanel.notifyHidden();
+ }
+ }
+
+ void writeProperties(java.util.Properties p) {
+ // better to version settings since initial version as advocated at
+ // http://wiki.apidesign.org/wiki/PropertyFiles
+ p.setProperty("version", "1.0"); //NOI18N
+ // TODO store your settings
+ }
+
+ void readProperties(java.util.Properties p) {
+ String version = p.getProperty("version");
+ // TODO read your settings according to their version
+ }
Review Comment:
this looks like it won't be needed and can be removed?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Add Dashboard API and use to provide replacement for Welcome page [netbeans]
Posted by "eirikbakke (via GitHub)" <gi...@apache.org>.
eirikbakke commented on PR #7239:
URL: https://github.com/apache/netbeans/pull/7239#issuecomment-2050060292
@neilcsmith-net Thanks for those notes! I haven't finished the design of the Ultorg welcome tab yet, but the current goal is to have it work like the "New Tab" tab in Google Chrome, where the welcome tab "becomes" the editor when you open an item from a Search bar or the Recents list, rather than opening a new tab. That's why I'm thinking of Ultorg's welcome tab more as an alternative panel in my existing custom TopComponent than as an entirely new kind of TopComponent.
One API feature that I will probably add for my own use is the ability to add "+" button after the row of tabs, which, if clicked, would open an application-specified "New Tab" tab.
I'll probably just hack my own access to relevant classes and APIs for now, and once my own code has stabilized and been in use for a while, I might request or propose relevant APIs to be opened.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Add Dashboard API and use to provide replacement for Welcome page [netbeans]
Posted by "mhalachev (via GitHub)" <gi...@apache.org>.
mhalachev commented on PR #7239:
URL: https://github.com/apache/netbeans/pull/7239#issuecomment-2042804263
Thanks @neilcsmith-net for the information regarding the actual widget implementation! I'll definitely look into it more extensively.
The overall concept of the Dashboard API is presenting a lot of opportunities. One may envision practical enhancements like Tasks and ToDos as widgets, and other stuff in the form of Plugins...
I hope the layout suggestions, albeit raw (spacers, headers, etc.), may offer utility for future use.
Meanwhile, I think I managed to fix the MacOS X theme border issue.
> I can confirm that it is now fine with Motif, but still with border with the Mac OS X theme:
<img width="260" alt="white-border" src="https://github.com/apache/netbeans/assets/2463597/f984a8d8-201c-41a5-bef2-cd1c533cf69b">
Setting the border to `0` in `WidgetPanel.java` (l. 107) seems to do the trick:
```java
scrollPane.setBorder(BorderFactory.createEmptyBorder());
```
PS: Can also confirm that looks good with CDE/Motif as well.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Add Dashboard API and use to provide replacement for Welcome page [netbeans]
Posted by "neilcsmith-net (via GitHub)" <gi...@apache.org>.
neilcsmith-net commented on code in PR #7239:
URL: https://github.com/apache/netbeans/pull/7239#discussion_r1559061630
##########
platform/api.dashboard/src/org/netbeans/modules/dashboard/WidgetComponents.java:
##########
@@ -0,0 +1,403 @@
+/*
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.dashboard;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Cursor;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.Image;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.net.URI;
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.BorderFactory;
+import javax.swing.Icon;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JSeparator;
+import javax.swing.JTextArea;
+import javax.swing.UIManager;
+import javax.swing.border.Border;
+import org.netbeans.spi.dashboard.WidgetElement;
+import org.netbeans.spi.dashboard.WidgetElement.ActionElement;
+import org.netbeans.spi.dashboard.WidgetElement.ComponentElement;
+import org.netbeans.spi.dashboard.WidgetElement.ImageElement;
+import org.netbeans.spi.dashboard.WidgetElement.LinkElement;
+import org.netbeans.spi.dashboard.WidgetElement.SeparatorElement;
+import org.netbeans.spi.dashboard.WidgetElement.TextElement;
+import org.openide.awt.HtmlBrowser;
+import org.openide.awt.StatusDisplayer;
+import org.openide.util.Exceptions;
+import org.openide.util.ImageUtilities;
+import org.openide.util.NbBundle;
+
+/**
+ * Default creation of JComponents for WidgetElements.
+ */
+@NbBundle.Messages({
+ "# {0} - link URI",
+ "TXT_statusLink=Open {0}"
+})
+final class WidgetComponents {
+
+ private WidgetComponents() {
+
+ }
+
+ static JComponent titleComponentFor(String title) {
+ MultiLineText text = new MultiLineText(title);
+ Font font = text.getFont();
+ text.setFont(font.deriveFont(font.getSize() * 1.4f));
+ return text;
+ }
+
+ static JComponent componentFor(WidgetElement element) {
+ if (element instanceof TextElement textElement) {
+ return componentForText(textElement);
+ } else if (element instanceof ImageElement imageElement) {
+ return componentForImage(imageElement);
+ } else if (element instanceof ActionElement actionElement) {
+ return componentForAction(actionElement);
+ } else if (element instanceof LinkElement linkElement) {
+ return componentForLink(linkElement);
+ } else if (element instanceof SeparatorElement sepElement) {
+ return componentForSeparator(sepElement);
+ } else if (element instanceof ComponentElement cmpElement) {
+ return cmpElement.component();
+ }
+ return null;
+ }
+
+ private static JComponent componentForText(TextElement element) {
+ MultiLineText text = new MultiLineText(element.text());
+ TextElement.Kind kind = element.kind();
+ if (kind == TextElement.Kind.SUBHEADING) {
+ Font font = text.getFont();
+ text.setFont(font.deriveFont(font.getSize() * 1.1f));
+ } else if (kind == TextElement.Kind.ASIDE || kind == TextElement.Kind.UNAVAILABLE) {
+ Font font = text.getFont();
+ text.setFont(font.deriveFont(font.getSize() * 0.9f));
+ Color color = UIManager.getColor("controlDkShadow");
+ if (color != null) {
+ text.setForeground(color);
+ }
+ }
+ return text;
+ }
+
+ private static JComponent componentForImage(ImageElement element) {
+ Image image = ImageUtilities.loadImage(element.resourcePath(), true);
+ Icon icon = ImageUtilities.image2Icon(image);
+ JLabel label = new JLabel(icon);
+ label.setMinimumSize(new Dimension(0, 0));
+ return label;
+ }
+
+ private static JComponent componentForAction(ActionElement element) {
+ if (element.asLink()) {
+ return new LinkButton(element.action(), element.showIcon());
+ } else {
+ return new WidgetButton(element.action(), element.showIcon());
+ }
+ }
+
+ private static JComponent componentForLink(LinkElement element) {
+ Action action = new URIOpenAction(element.text(), element.link());
+ if (element.asButton()) {
+ return new WidgetButton(action, false);
+ } else {
+ return new LinkButton(action, false);
+ }
+ }
+
+ private static JComponent componentForSeparator(WidgetElement.SeparatorElement element) {
+ JSeparator sep = new JSeparator();
+ sep.setPreferredSize(new Dimension(75, 8));
+ return sep;
+ }
+
+ private static class MultiLineText extends JTextArea {
+
+ private MultiLineText(String text) {
+ super(text);
+ setEditable(false);
+ setCursor(null);
+ setOpaque(false);
+ // some LAFs (looking at you Nimbus!) require transparent bg color
+ setBackground(new Color(0, 0, 0, 0));
+ setFocusable(false);
+ setBorder(BorderFactory.createEmptyBorder());
+ setMargin(new Insets(0, 0, 0, 0));
+ Font labelFont = UIManager.getFont("Label.font");
+ if (labelFont != null) {
+ setFont(labelFont);
+ }
+ Color labelColor = UIManager.getColor("Label.foreground");
+ if (labelColor != null) {
+ setForeground(labelColor);
+ }
+ setWrapStyleWord(true);
+ setLineWrap(true);
+ }
+
+ }
+
+ private static abstract class AbstractWidgetButton extends JButton {
+
+ private final boolean allowIcon;
+
+ private AbstractWidgetButton(Action action, boolean allowIcon) {
+ super(action);
+ this.allowIcon = allowIcon;
+ if (!allowIcon) {
+ setIcon(null);
+ }
+ setHorizontalAlignment(LEFT);
+ setToolTipText(null);
+ addMouseListener(new MouseAdapter() {
+
+ @Override
+ public void mouseEntered(MouseEvent e) {
+ onMouseEnter();
+ }
+
+ @Override
+ public void mouseExited(MouseEvent e) {
+ onMouseExit();
+ }
+
+ });
+ }
+
+ void onMouseEnter() {
+ Action action = getAction();
+ if (action != null) {
+ Object status = action.getValue(Action.SHORT_DESCRIPTION);
+ if (status instanceof String statusText) {
+ StatusDisplayer.getDefault().setStatusText(statusText);
+ }
+ }
+ }
+
+ void onMouseExit() {
+ StatusDisplayer.getDefault().setStatusText("");
+ }
+
+ @Override
+ protected void actionPropertyChanged(Action action, String propertyName) {
+ if (allowedPropertyChange(propertyName)) {
+ super.actionPropertyChanged(action, propertyName);
+ }
+ }
+
+ private boolean allowedPropertyChange(String propertyName) {
+ return switch (propertyName) {
+ case Action.SMALL_ICON ->
+ allowIcon;
+ case Action.LARGE_ICON_KEY ->
+ allowIcon;
+ case Action.SHORT_DESCRIPTION ->
+ false;
+ case Action.LONG_DESCRIPTION ->
+ false;
+ default ->
+ true;
+ };
Review Comment:
Yes, that needs considering. We could do with looking at the formatting on a few recent features.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Add Dashboard API and use to provide replacement for Welcome page [netbeans]
Posted by "neilcsmith-net (via GitHub)" <gi...@apache.org>.
neilcsmith-net commented on code in PR #7239:
URL: https://github.com/apache/netbeans/pull/7239#discussion_r1559067653
##########
platform/api.dashboard/src/org/netbeans/modules/dashboard/DashboardTopComponent.java:
##########
@@ -0,0 +1,222 @@
+/*
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.dashboard;
+
+import java.util.List;
+import org.netbeans.api.dashboard.DashboardManager;
+import org.netbeans.api.settings.ConvertAsProperties;
+import org.netbeans.spi.dashboard.DashboardDisplayer;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.windows.TopComponent;
+import org.openide.util.NbBundle.Messages;
+import org.openide.windows.OnShowing;
+import org.openide.windows.WindowManager;
+import org.openide.windows.WindowSystemEvent;
+import org.openide.windows.WindowSystemListener;
+
+/**
+ * Default Dashboard Displayer top component.
+ */
+@ConvertAsProperties(
+ dtd = "-//org.netbeans.modules.dashboard//Dashboard//EN",
+ autostore = false
+)
+@TopComponent.Description(
+ preferredID = "DashboardDisplayer",
+ persistenceType = TopComponent.PERSISTENCE_ONLY_OPENED
+)
+@TopComponent.Registration(mode = "editor", openAtStartup = false, position = 0)
+@Messages({
+ "CTL_DashboardTopComponent=Dashboard",
+ "HINT_DashboardTopComponent=The Dashboard window"
+})
+public final class DashboardTopComponent extends TopComponent {
+
+ private static final String ID = "DashboardDisplayer";
+
+ private List<DashboardDisplayer.WidgetReference> widgetRefs;
+ private DashboardPanel dashboardPanel;
+
+ public DashboardTopComponent() {
+ initComponents();
+ scrollPane.getVerticalScrollBar().setUnitIncrement(20);
+ setName(Bundle.CTL_DashboardTopComponent());
+ setToolTipText(Bundle.HINT_DashboardTopComponent());
+ }
+
+ /**
+ * This method is called from within the constructor to initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is always
+ * regenerated by the Form Editor.
+ */
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ scrollPane = new javax.swing.JScrollPane();
+ dashContainer = new javax.swing.JPanel();
+ emptyLabel = new javax.swing.JLabel();
+
+ setLayout(new java.awt.BorderLayout());
+
+ scrollPane.setBorder(null);
+ scrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
+ scrollPane.setViewportBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
+
+ dashContainer.setLayout(new java.awt.GridBagLayout());
+
+ org.openide.awt.Mnemonics.setLocalizedText(emptyLabel, org.openide.util.NbBundle.getMessage(DashboardTopComponent.class, "DashboardTopComponent.emptyLabel.text")); // NOI18N
+ dashContainer.add(emptyLabel, new java.awt.GridBagConstraints());
+
+ scrollPane.setViewportView(dashContainer);
+
+ add(scrollPane, java.awt.BorderLayout.CENTER);
+ }// </editor-fold>//GEN-END:initComponents
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JPanel dashContainer;
+ private javax.swing.JLabel emptyLabel;
+ private javax.swing.JScrollPane scrollPane;
+ // End of variables declaration//GEN-END:variables
+ @Override
+ public void componentShowing() {
+ if (dashboardPanel != null) {
+ dashboardPanel.notifyShowing();
+ }
+ }
+
+ @Override
+ public void componentHidden() {
+ if (dashboardPanel != null) {
+ dashboardPanel.notifyHidden();
+ }
+ }
+
+ void writeProperties(java.util.Properties p) {
+ // better to version settings since initial version as advocated at
+ // http://wiki.apidesign.org/wiki/PropertyFiles
+ p.setProperty("version", "1.0"); //NOI18N
+ // TODO store your settings
+ }
+
+ void readProperties(java.util.Properties p) {
+ String version = p.getProperty("version");
+ // TODO read your settings according to their version
+ }
Review Comment:
We have a [few of these](https://github.com/search?q=repo%3Aapache%2Fnetbeans%20http%3A%2F%2Fwiki.apidesign.org%2Fwiki%2FPropertyFiles&type=code). Including in another `DashboardTopComponent`, which confused me for a second. Thankfully IDs are different.
I took this out at one point, but it's linked to `@ConvertAsProperties` and I'm not sure whether we might have a need for that in future. In which case the TODO in the generated code is OK to me.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Add Dashboard API and use to provide replacement for Welcome page [netbeans]
Posted by "neilcsmith-net (via GitHub)" <gi...@apache.org>.
neilcsmith-net commented on PR #7239:
URL: https://github.com/apache/netbeans/pull/7239#issuecomment-2047804919
@mbien it's not API, and it's already removed from the list of modules for the source zip and build, but not from the repository, as part of this. I am planning to put in a follow up PR to remove the module code during NB23, once we're sure everything in there is no longer required.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Add Dashboard API and use to provide replacement for Welcome page [netbeans]
Posted by "neilcsmith-net (via GitHub)" <gi...@apache.org>.
neilcsmith-net commented on PR #7239:
URL: https://github.com/apache/netbeans/pull/7239#issuecomment-2037721786
I've pushed a change to disable on start by default. And fixed the issue with the background editor actions not showing - bizarrely caused by the removed Welcome component not opening and closing before display. Also added the missing license text rat was complaining about in the generated arch.xml.
@mbien I'm not a fan of behaviour changes based on how many times you've run something - I think it's confusing for the user. I've disabled for now, and possibly we go with this for now while it matures? However, one other option would be to make the `showOnStartup` attribute an enum rather than a boolean flag - with `Never`, `Always` and `WithOpenEditors` or similar?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Add Dashboard API and use to provide replacement for Welcome page [netbeans]
Posted by "mhalachev (via GitHub)" <gi...@apache.org>.
mhalachev commented on PR #7239:
URL: https://github.com/apache/netbeans/pull/7239#issuecomment-2047684058
> PS: Just noticed something... the shortcut color in https://github.com/apache/netbeans/pull/7171 also gets black with CDE/Motif and Mac OS X themes:
I can confirm that this works as expected and colors appear in editor background like in the Dashboard while using the aforementioned themes:
```diff
diff --git a/platform/core.windows/src/org/netbeans/core/windows/view/EditorView.java b/platform/core.windows/src/org/netbeans/core/windows/view/EditorView.java
index 40662c1af7..32b59cbf52 100644
--- a/platform/core.windows/src/org/netbeans/core/windows/view/EditorView.java
+++ b/platform/core.windows/src/org/netbeans/core/windows/view/EditorView.java
@@ -487,6 +487,9 @@ public class EditorView extends ViewElement {
Color shortcutColor = UIManager.getColor("EditorTab.underlineColor");
if (shortcutColor != null) {
shortcut.setTitleColor(shortcutColor);
+ } else {
+ shortcutColor = new Color(0x164B7B);
+ shortcut.setTitleColor(shortcutColor);
}
Font font = getFont();
if (font != null) {
```
Result:
<img width="310" alt="motif-fixed" src="https://github.com/apache/netbeans/assets/2463597/0812d2c6-d914-419b-a924-c30839c7adde">
@neilcsmith-net Could we get this in here, without another PR? It fixes the same theme-specific color issue...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Add Dashboard API and use to provide replacement for Welcome page [netbeans]
Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #7239:
URL: https://github.com/apache/netbeans/pull/7239#discussion_r1558690317
##########
platform/api.dashboard/src/org/netbeans/modules/dashboard/WidgetComponents.java:
##########
@@ -0,0 +1,403 @@
+/*
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.dashboard;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Cursor;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.Image;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.net.URI;
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.BorderFactory;
+import javax.swing.Icon;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JSeparator;
+import javax.swing.JTextArea;
+import javax.swing.UIManager;
+import javax.swing.border.Border;
+import org.netbeans.spi.dashboard.WidgetElement;
+import org.netbeans.spi.dashboard.WidgetElement.ActionElement;
+import org.netbeans.spi.dashboard.WidgetElement.ComponentElement;
+import org.netbeans.spi.dashboard.WidgetElement.ImageElement;
+import org.netbeans.spi.dashboard.WidgetElement.LinkElement;
+import org.netbeans.spi.dashboard.WidgetElement.SeparatorElement;
+import org.netbeans.spi.dashboard.WidgetElement.TextElement;
+import org.openide.awt.HtmlBrowser;
+import org.openide.awt.StatusDisplayer;
+import org.openide.util.Exceptions;
+import org.openide.util.ImageUtilities;
+import org.openide.util.NbBundle;
+
+/**
+ * Default creation of JComponents for WidgetElements.
+ */
+@NbBundle.Messages({
+ "# {0} - link URI",
+ "TXT_statusLink=Open {0}"
+})
+final class WidgetComponents {
+
+ private WidgetComponents() {
+
+ }
+
+ static JComponent titleComponentFor(String title) {
+ MultiLineText text = new MultiLineText(title);
+ Font font = text.getFont();
+ text.setFont(font.deriveFont(font.getSize() * 1.4f));
+ return text;
+ }
+
+ static JComponent componentFor(WidgetElement element) {
+ if (element instanceof TextElement textElement) {
+ return componentForText(textElement);
+ } else if (element instanceof ImageElement imageElement) {
+ return componentForImage(imageElement);
+ } else if (element instanceof ActionElement actionElement) {
+ return componentForAction(actionElement);
+ } else if (element instanceof LinkElement linkElement) {
+ return componentForLink(linkElement);
+ } else if (element instanceof SeparatorElement sepElement) {
+ return componentForSeparator(sepElement);
+ } else if (element instanceof ComponentElement cmpElement) {
+ return cmpElement.component();
+ }
+ return null;
+ }
+
+ private static JComponent componentForText(TextElement element) {
+ MultiLineText text = new MultiLineText(element.text());
+ TextElement.Kind kind = element.kind();
+ if (kind == TextElement.Kind.SUBHEADING) {
+ Font font = text.getFont();
+ text.setFont(font.deriveFont(font.getSize() * 1.1f));
+ } else if (kind == TextElement.Kind.ASIDE || kind == TextElement.Kind.UNAVAILABLE) {
+ Font font = text.getFont();
+ text.setFont(font.deriveFont(font.getSize() * 0.9f));
+ Color color = UIManager.getColor("controlDkShadow");
+ if (color != null) {
+ text.setForeground(color);
+ }
+ }
+ return text;
+ }
+
+ private static JComponent componentForImage(ImageElement element) {
+ Image image = ImageUtilities.loadImage(element.resourcePath(), true);
+ Icon icon = ImageUtilities.image2Icon(image);
+ JLabel label = new JLabel(icon);
+ label.setMinimumSize(new Dimension(0, 0));
+ return label;
+ }
+
+ private static JComponent componentForAction(ActionElement element) {
+ if (element.asLink()) {
+ return new LinkButton(element.action(), element.showIcon());
+ } else {
+ return new WidgetButton(element.action(), element.showIcon());
+ }
+ }
+
+ private static JComponent componentForLink(LinkElement element) {
+ Action action = new URIOpenAction(element.text(), element.link());
+ if (element.asButton()) {
+ return new WidgetButton(action, false);
+ } else {
+ return new LinkButton(action, false);
+ }
+ }
+
+ private static JComponent componentForSeparator(WidgetElement.SeparatorElement element) {
+ JSeparator sep = new JSeparator();
+ sep.setPreferredSize(new Dimension(75, 8));
+ return sep;
+ }
+
+ private static class MultiLineText extends JTextArea {
+
+ private MultiLineText(String text) {
+ super(text);
+ setEditable(false);
+ setCursor(null);
+ setOpaque(false);
+ // some LAFs (looking at you Nimbus!) require transparent bg color
+ setBackground(new Color(0, 0, 0, 0));
+ setFocusable(false);
+ setBorder(BorderFactory.createEmptyBorder());
+ setMargin(new Insets(0, 0, 0, 0));
+ Font labelFont = UIManager.getFont("Label.font");
+ if (labelFont != null) {
+ setFont(labelFont);
+ }
+ Color labelColor = UIManager.getColor("Label.foreground");
+ if (labelColor != null) {
+ setForeground(labelColor);
+ }
+ setWrapStyleWord(true);
+ setLineWrap(true);
+ }
+
+ }
+
+ private static abstract class AbstractWidgetButton extends JButton {
+
+ private final boolean allowIcon;
+
+ private AbstractWidgetButton(Action action, boolean allowIcon) {
+ super(action);
+ this.allowIcon = allowIcon;
+ if (!allowIcon) {
+ setIcon(null);
+ }
+ setHorizontalAlignment(LEFT);
+ setToolTipText(null);
+ addMouseListener(new MouseAdapter() {
+
+ @Override
+ public void mouseEntered(MouseEvent e) {
+ onMouseEnter();
+ }
+
+ @Override
+ public void mouseExited(MouseEvent e) {
+ onMouseExit();
+ }
+
+ });
+ }
+
+ void onMouseEnter() {
+ Action action = getAction();
+ if (action != null) {
+ Object status = action.getValue(Action.SHORT_DESCRIPTION);
+ if (status instanceof String statusText) {
+ StatusDisplayer.getDefault().setStatusText(statusText);
+ }
+ }
+ }
+
+ void onMouseExit() {
+ StatusDisplayer.getDefault().setStatusText("");
+ }
+
+ @Override
+ protected void actionPropertyChanged(Action action, String propertyName) {
+ if (allowedPropertyChange(propertyName)) {
+ super.actionPropertyChanged(action, propertyName);
+ }
+ }
+
+ private boolean allowedPropertyChange(String propertyName) {
+ return switch (propertyName) {
+ case Action.SMALL_ICON ->
+ allowIcon;
+ case Action.LARGE_ICON_KEY ->
+ allowIcon;
+ case Action.SHORT_DESCRIPTION ->
+ false;
+ case Action.LONG_DESCRIPTION ->
+ false;
+ default ->
+ true;
+ };
Review Comment:
probably going to have to fix the formatter for this one day so that switch statements can be written like:
```java
return switch (propertyName) {
case Action.SMALL_ICON -> allowIcon;
case Action.LARGE_ICON_KEY -> allowIcon;
case Action.SHORT_DESCRIPTION -> false;
case Action.LONG_DESCRIPTION -> false;
default -> true;
};
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Add Dashboard API and use to provide replacement for Welcome page [netbeans]
Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on PR #7239:
URL: https://github.com/apache/netbeans/pull/7239#issuecomment-2037562471
could the dashboard open on second launch? The new minimalistic empty-editor-pane has all the bootstrap actions already and once the user has something open there would be no empty pane anyway, thats when the dashboard becomes more useful.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Add Dashboard API and use to provide replacement for Welcome page [netbeans]
Posted by "neilcsmith-net (via GitHub)" <gi...@apache.org>.
neilcsmith-net commented on PR #7239:
URL: https://github.com/apache/netbeans/pull/7239#issuecomment-2042584012
@Chris2011 I wasn't proposing anything more complicated in the IDE dashboard than a checkbox, just whether the API (and the `showOnStartup` attribute is effectively part of that) should be able to handle more options than a simple boolean.
This PR adds a new platform API as well as a new IDE dashboard. While it's marked as still in development, it would be good to review that aspect, and apply any necessary changes, so that this can be merged this week if it's going to go in at all.
Adding `Platform` label as well as temporarily `ci:all-tests` in case the additional modules cause anything to need to be addressed. Might need excluding in VSCode for now?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Add Dashboard API and use to provide replacement for Welcome page [netbeans]
Posted by "neilcsmith-net (via GitHub)" <gi...@apache.org>.
neilcsmith-net commented on PR #7239:
URL: https://github.com/apache/netbeans/pull/7239#issuecomment-2047722129
@mhalachev please open another PR for that one.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Add Dashboard API and use to provide replacement for Welcome page [netbeans]
Posted by "Chris2011 (via GitHub)" <gi...@apache.org>.
Chris2011 commented on PR #7239:
URL: https://github.com/apache/netbeans/pull/7239#issuecomment-2041603014
Just make it simple as possible as you alraedy have the checkbox "show on startup". Thats it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Add Dashboard API and use to provide replacement for Welcome page [netbeans]
Posted by "neilcsmith-net (via GitHub)" <gi...@apache.org>.
neilcsmith-net commented on PR #7239:
URL: https://github.com/apache/netbeans/pull/7239#issuecomment-2036914003
Thanks @ebarboni - specifically this is using (hopefully correctly!) the approach outlined at https://netbeans.apache.org/wiki/main/wiki/APIDevelopment/#Support_for_Early_Adoption
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Add Dashboard API and use to provide replacement for Welcome page [netbeans]
Posted by "mhalachev (via GitHub)" <gi...@apache.org>.
mhalachev commented on PR #7239:
URL: https://github.com/apache/netbeans/pull/7239#issuecomment-2039751712
@neilcsmith-net Looks very nice! :) Below are some suggestions, partially inspired by the old Welcome screen which actually contains some helpful information scattered across the tabs.
Should the layout be rearranged a little bit, an additional pane may be placed, for example, a set of links to demos and tutorials, or something else:

With a little bit of rearrangement a 3x2 layout may be obtained in a way, that on the first row, there will be items that can be open (projects, files, tutorials), and on the second -- items related to the IDE itself:
Eventually, the atom feed (preferably with the latest item only) may be added below as a "counterweight" to the header. It is also useful -- actually, I often get the new release announcements there first :)
Here is a mockup of what it might look like:

What about making the dashboard itself customisable in future releases, so that the user can add/remove and rearrange items?
P.S. Noticed a small glitch with the dev build: While using some themes (CDE/Motif, Mac OS X), each pane is delineated by borders, and the links/buttons share the same color as the main text:
<img width="791" alt="motif" src="https://github.com/apache/netbeans/assets/2463597/b889257f-a4fc-405a-ae17-8ad55da009da">
<img width="787" alt="macosx" src="https://github.com/apache/netbeans/assets/2463597/0a748520-8fa9-4e0b-bfe4-8a288a096b0a">
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Add Dashboard API and use to provide replacement for Welcome page [netbeans]
Posted by "neilcsmith-net (via GitHub)" <gi...@apache.org>.
neilcsmith-net commented on PR #7239:
URL: https://github.com/apache/netbeans/pull/7239#issuecomment-2039890259
Have hopefully fixed the issue with the viewport border, link colours and hover underline on a few non-default LAFs. Seems OK on Motif, but not verified macOS yet.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Add Dashboard API and use to provide replacement for Welcome page [netbeans]
Posted by "neilcsmith-net (via GitHub)" <gi...@apache.org>.
neilcsmith-net commented on code in PR #7239:
URL: https://github.com/apache/netbeans/pull/7239#discussion_r1559059391
##########
platform/api.dashboard/src/org/netbeans/modules/dashboard/DashboardTopComponent.java:
##########
@@ -0,0 +1,222 @@
+/*
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.dashboard;
+
+import java.util.List;
+import org.netbeans.api.dashboard.DashboardManager;
+import org.netbeans.api.settings.ConvertAsProperties;
+import org.netbeans.spi.dashboard.DashboardDisplayer;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.windows.TopComponent;
+import org.openide.util.NbBundle.Messages;
+import org.openide.windows.OnShowing;
+import org.openide.windows.WindowManager;
+import org.openide.windows.WindowSystemEvent;
+import org.openide.windows.WindowSystemListener;
+
+/**
+ * Default Dashboard Displayer top component.
+ */
+@ConvertAsProperties(
+ dtd = "-//org.netbeans.modules.dashboard//Dashboard//EN",
+ autostore = false
+)
+@TopComponent.Description(
+ preferredID = "DashboardDisplayer",
+ persistenceType = TopComponent.PERSISTENCE_ONLY_OPENED
+)
+@TopComponent.Registration(mode = "editor", openAtStartup = false, position = 0)
+@Messages({
+ "CTL_DashboardTopComponent=Dashboard",
+ "HINT_DashboardTopComponent=The Dashboard window"
+})
+public final class DashboardTopComponent extends TopComponent {
+
+ private static final String ID = "DashboardDisplayer";
+
+ private List<DashboardDisplayer.WidgetReference> widgetRefs;
+ private DashboardPanel dashboardPanel;
+
+ public DashboardTopComponent() {
+ initComponents();
+ scrollPane.getVerticalScrollBar().setUnitIncrement(20);
+ setName(Bundle.CTL_DashboardTopComponent());
+ setToolTipText(Bundle.HINT_DashboardTopComponent());
+ }
+
+ /**
+ * This method is called from within the constructor to initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is always
+ * regenerated by the Form Editor.
+ */
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ scrollPane = new javax.swing.JScrollPane();
+ dashContainer = new javax.swing.JPanel();
+ emptyLabel = new javax.swing.JLabel();
+
+ setLayout(new java.awt.BorderLayout());
+
+ scrollPane.setBorder(null);
+ scrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
+ scrollPane.setViewportBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
+
+ dashContainer.setLayout(new java.awt.GridBagLayout());
+
+ org.openide.awt.Mnemonics.setLocalizedText(emptyLabel, org.openide.util.NbBundle.getMessage(DashboardTopComponent.class, "DashboardTopComponent.emptyLabel.text")); // NOI18N
+ dashContainer.add(emptyLabel, new java.awt.GridBagConstraints());
+
+ scrollPane.setViewportView(dashContainer);
+
+ add(scrollPane, java.awt.BorderLayout.CENTER);
+ }// </editor-fold>//GEN-END:initComponents
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JPanel dashContainer;
+ private javax.swing.JLabel emptyLabel;
+ private javax.swing.JScrollPane scrollPane;
+ // End of variables declaration//GEN-END:variables
+ @Override
+ public void componentShowing() {
+ if (dashboardPanel != null) {
+ dashboardPanel.notifyShowing();
+ }
+ }
+
+ @Override
+ public void componentHidden() {
+ if (dashboardPanel != null) {
+ dashboardPanel.notifyHidden();
+ }
+ }
+
+ void writeProperties(java.util.Properties p) {
+ // better to version settings since initial version as advocated at
+ // http://wiki.apidesign.org/wiki/PropertyFiles
+ p.setProperty("version", "1.0"); //NOI18N
+ // TODO store your settings
+ }
+
+ void readProperties(java.util.Properties p) {
+ String version = p.getProperty("version");
+ // TODO read your settings according to their version
+ }
+
+ private void installWidgets(DefaultDashboardDisplayer displayer,
+ List<DashboardDisplayer.WidgetReference> widgetRefs) {
+ if (this.widgetRefs != null) {
+ if (this.widgetRefs.equals(widgetRefs)) {
+ return;
+ }
+ }
+ this.widgetRefs = List.copyOf(widgetRefs);
+ // TODO allow panel to be reconfigured at runtime, and detach removed widgets
+ this.dashboardPanel = new DashboardPanel(displayer, widgetRefs);
+ dashContainer.removeAll();
+ dashContainer.add(this.dashboardPanel);
+ dashboardPanel.notifyShowing();
+ }
+
+ static void show(DefaultDashboardDisplayer displayer,
+ List<DashboardDisplayer.WidgetReference> widgetRefs) {
+ DashboardTopComponent dashTC = find();
+ if (dashTC == null) {
+ return;
+ }
+ if (widgetRefs.isEmpty()) {
+ dashTC.close();
+ return;
+ }
+ dashTC.installWidgets(displayer, widgetRefs);
+ if (!dashTC.isOpened()) {
+ dashTC.openAtTabPosition(0);
+ }
+ dashTC.requestActive();
+ }
+
+ private static DashboardTopComponent find() {
+ TopComponent tc = WindowManager.getDefault().findTopComponent(ID);
+ if (tc instanceof DashboardTopComponent dashTC) {
+ return dashTC;
+ } else {
+ return null;
+ }
Review Comment:
Yes, and I _am_ a [fan of ternary expressions](https://www.youtube.com/watch?v=tkJxd2IOQQY), but I'm not sure it makes it more legible here. :smile:
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Add Dashboard API and use to provide replacement for Welcome page [netbeans]
Posted by "ebarboni (via GitHub)" <gi...@apache.org>.
ebarboni commented on PR #7239:
URL: https://github.com/apache/netbeans/pull/7239#issuecomment-2036909039
make sense
just a pointer for API related tasks that look or in this PR for me, https://netbeans.apache.org/wiki/main/wiki/APIDevelopment/ (not reviewed)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Add Dashboard API and use to provide replacement for Welcome page [netbeans]
Posted by "mhalachev (via GitHub)" <gi...@apache.org>.
mhalachev commented on PR #7239:
URL: https://github.com/apache/netbeans/pull/7239#issuecomment-2045491454
> hopefully this change fixes things. I can't remember why the extra pixel was there, but seems OK without now, and I guess was allowing a background colour to show through???
@neilcsmith-net I can confirm that it now works as expected:
<img width="262" alt="macos-theme" src="https://github.com/apache/netbeans/assets/2463597/0b09da2a-33b1-47d9-bba0-1fe050e5c77d">
Indeed, it was possibly either a background color popping in or an explicitly set border in the theme if the default is transparent...
PS: Just noticed something... the shortcut color in https://github.com/apache/netbeans/pull/7171 also gets black with CDE/Motif and Mac OS X themes:
<img width="356" alt="Motif" src="https://github.com/apache/netbeans/assets/2463597/cea6dfa5-52c0-45ac-90cd-fbee0bf42c8d">
Here is FlatLaf (blue):
<img width="338" alt="FlatLaf" src="https://github.com/apache/netbeans/assets/2463597/c17b1263-4e1b-4940-b65e-917bc2fb5601">
Maybe it could be fixed similarly to links and buttons colours for the dashboard, but for the shortcut color in the editor background... 🤔
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Add Dashboard API and use to provide replacement for Welcome page [netbeans]
Posted by "mhalachev (via GitHub)" <gi...@apache.org>.
mhalachev commented on PR #7239:
URL: https://github.com/apache/netbeans/pull/7239#issuecomment-2039949070
Thanks @neilcsmith-net
I missed that the view is actually fluid, which is actually also useful as the dash can be kept visible as a narrow side pane:
<img width="1032" alt="side-dash" src="https://github.com/apache/netbeans/assets/2463597/eab76593-6dba-42b5-9fee-4b1d27debafd">
Regarding the "header" layout, what about a little trick, with an additional row to hold separate dashboard items?

In this case, given that the layout is fluid, it possibly should fold like this by itself in a narrow window:

--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Add Dashboard API and use to provide replacement for Welcome page [netbeans]
Posted by "neilcsmith-net (via GitHub)" <gi...@apache.org>.
neilcsmith-net commented on PR #7239:
URL: https://github.com/apache/netbeans/pull/7239#issuecomment-2045328313
> My environment system is currently set up to use Java 11. Is NetBeans supposed to require a higher Java version to build these days?
Yes, Java 17 from NetBeans 22. As this is a completely new API, and there are some benefits to using 17, I did so.
> Ooh, nice work!
Thanks! :smile: Do you think this is something you might find useful in a platform application? If so, are there any concerns or things you'd like to see even in this first iteration?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Add Dashboard API and use to provide replacement for Welcome page [netbeans]
Posted by "neilcsmith-net (via GitHub)" <gi...@apache.org>.
neilcsmith-net commented on PR #7239:
URL: https://github.com/apache/netbeans/pull/7239#issuecomment-2039827178
Thanks @mhalachev
Header and footer elements are unlikely to be added, because the default displayer is not a fixed 3x2 grid - it's fluid. Nor is a dashboard displayer guaranteed to have that configuration. It might be possible to consider, but it would take some thought to incorporate into the API, and I'm not convinced it's actually desirable.
> What about making the dashboard itself customisable in future releases, so that the user can add/remove and rearrange items?
Yes! The API is designed to allow this, and already provides the ability for platform applications to register their own widgets for display. A UI for customization can hopefully come in the next release or so, but without a selection of other widgets to display, doesn't offer much at this stage besides moving around what's there. This is covered in the description. One step at a time! :smile:
> an additional pane may be placed, for example, a set of links to demos and tutorials,
These were left out deliberately at this stage, because I think we need to look at providing useful and current demos and tutorials if we're going to put them front and centre. There is the possibility of linking these into `Learn & Discover` already - I don't think we need another widget for that. That's where they are on the old welcome page. We could consider a link to https://netbeans.apache.org/tutorial/main/kb/docs/ but that landing page should probably be rearranged. The sample projects need to probably include something other than Ant for Java!
> Eventually, the atom feed ...
A feed widget is possible. _But_, if the only point of the feed is to give notification of a new release (and that's all that's been there for a long time!) we already have another mechanism for that. I started looking at making the `Check for Updates` link dynamic so that it eg. changes to `Updates Available`, `New IDE release available`, etc. It would probably also change from hyperlink to button to grab attention.
> each pane is delineated by borders ...
Yes, thanks. I'd noticed on macOS, but hadn't checked with Motif. The code removes the scrollpane border, but not the one some UIs set on the viewport. Will look at fixing that and update this PR before moving out of draft.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Add Dashboard API and use to provide replacement for Welcome page [netbeans]
Posted by "neilcsmith-net (via GitHub)" <gi...@apache.org>.
neilcsmith-net commented on PR #7239:
URL: https://github.com/apache/netbeans/pull/7239#issuecomment-2049604219
@eirikbakke the platform API is designed for this purpose. In fact, none of the IDE's widgets can be reused in the platform currently - the files and projects widgets require friends access for now, but could move into those modules for reuse later.
The API supports alternative displayers. You could certainly display it wherever you want, including in a custom TopComponent. The missing piece at the moment is an SPI support class to access the default Swing-based panel, widget and component renderers. You'd have to copy that across. I was planning that access as part of the additional improvements I personally intend to work on for this in NB23, alongside those in the original description. If access to that is useful for you earlier, it's an easy addition for NB22. Just say. I'm personally going to be using the default displayer for now.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Add Dashboard API and use to provide replacement for Welcome page [netbeans]
Posted by "eirikbakke (via GitHub)" <gi...@apache.org>.
eirikbakke commented on PR #7239:
URL: https://github.com/apache/netbeans/pull/7239#issuecomment-2049409477
@neilcsmith-net Adding a Welcome page to Ultorg is actually on my short-term TODO list. My platform app has its own project management system (not the NetBeans Projects/Files API anymore), and an existing TopComponent subclass that I need to reuse, so I probably will end up with a custom impementation. But I find it very useful to look at existing NetBeans code to see how similar things are done within the framework of the platform. I'll be using your code as a reference!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Add Dashboard API and use to provide replacement for Welcome page [netbeans]
Posted by "neilcsmith-net (via GitHub)" <gi...@apache.org>.
neilcsmith-net merged PR #7239:
URL: https://github.com/apache/netbeans/pull/7239
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Add Dashboard API and use to provide replacement for Welcome page [netbeans]
Posted by "eirikbakke (via GitHub)" <gi...@apache.org>.
eirikbakke commented on PR #7239:
URL: https://github.com/apache/netbeans/pull/7239#issuecomment-2045300616
Ooh, nice work! Trying to build NetBeans with this patch included, I get the following error:
```
-do-compile:
[nb-javac] Compiling 10 source files to Z:\nbsrc\incubator-netbeans\platform\api.dashboard\build\classes
[nb-javac] Ignoring source, target and bootclasspath as release has been set
[repeat] error: release version 17 not supported
[repeat] Usage: javac <options> <source files>
[repeat] use --help for a list of possible options
[nbmerge] Failed to build target: all-api.dashboard
```
My environment system is currently set up to use Java 11. Is NetBeans supposed to require a higher Java version to build these days?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Add Dashboard API and use to provide replacement for Welcome page [netbeans]
Posted by "neilcsmith-net (via GitHub)" <gi...@apache.org>.
neilcsmith-net commented on PR #7239:
URL: https://github.com/apache/netbeans/pull/7239#issuecomment-2042846817
Thanks @mhalachev - hopefully this change fixes things. I can't remember why the extra pixel was there, but seems OK without now, and I guess was allowing a background colour to show through???
> The overall concept of the Dashboard API is presenting a lot of opportunities. One may envision practical enhancements like Tasks and ToDos as widgets, and other stuff in the form of Plugins...
Thanks. Yes, that's definitely part of my thinking, and allowing these things to be in the relevant modules, not require exposing API, while keeping the overall display coordinated.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Add Dashboard API and use to provide replacement for Welcome page [netbeans]
Posted by "neilcsmith-net (via GitHub)" <gi...@apache.org>.
neilcsmith-net commented on PR #7239:
URL: https://github.com/apache/netbeans/pull/7239#issuecomment-2039992048
That could involve widgets knowing far more about how they're displayed than I wanted to expose. At the moment a widget is just an instance registered in the layer file system that produces a list of logical elements that it wants to display (eg. text, image, link). How those elements are rendered is in the hands of the displayer.
See eg. https://github.com/apache/netbeans/blob/55834afe83a504f9854bab2297f776cc3fe010ac/nb/ide.dashboard/src/org/netbeans/modules/ide/dashboard/HelpWidget.java and the available element types https://github.com/apache/netbeans/blob/55834afe83a504f9854bab2297f776cc3fe010ac/platform/api.dashboard/src/org/netbeans/spi/dashboard/WidgetElement.java These things deliberately know nothing about how they are displayed, or have any reference to grids, size or Swing.
Fluid sized widgets could be a thing, along with a spacer (empty) widget, to achieve your suggested rendering. It was a lot easier to achieve the fluid grid with fixed size widgets though!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Add Dashboard API and use to provide replacement for Welcome page [netbeans]
Posted by "neilcsmith-net (via GitHub)" <gi...@apache.org>.
neilcsmith-net commented on PR #7239:
URL: https://github.com/apache/netbeans/pull/7239#issuecomment-2046936114
Thanks @mbien With regards colours, I kept the default background and opaque components (for now at least) for a number of reasons - it should hopefully work across all LAFs (even if we don't support them!); it blends with the active tab colour (which Eirik pointed out in discussions about the new tabs); and I'd still like to look at an alternative overlay displayer in future anyway, which would make sense of higher contrast colours.
I'll squash this and prepare for merging tomorrow unless anyone has additional comments / changes they want to see?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Add Dashboard API and use to provide replacement for Welcome page [netbeans]
Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on PR #7239:
URL: https://github.com/apache/netbeans/pull/7239#issuecomment-2047758878
I forgot to mention: please check if the old welcome page code can be removed during NB 23 dev cycle. I don't think its public api, if it is, it should be deprecated asap, ideally with this PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists