Skip to content

Commit

Permalink
Notifications manager added
Browse files Browse the repository at this point in the history
AbstractLayoutManager.java class added to simplify layout coding
All custom layout managers refactored and now built upon AbstractLayoutManager.java (which implements Swing LayoutManager2)
MultiLayout.java added which can provide multiply layouts support to any container, its still up to you which layout wil handle each type of components
MultiLayout.java is set into each WebGlassPane.java at creation and glass pane supports multiply layouts at the same time now
Optimizations made to default listeners list sizes in all WebLaF components
  • Loading branch information
mgarin committed Sep 2, 2013
1 parent 2f76343 commit 299bfc5
Show file tree
Hide file tree
Showing 122 changed files with 4,353 additions and 1,090 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Artifacts
You can always find all WebLaF releases in the "releases" section:<br>
https://github.com/mgarin/weblaf/releases

Here are the direct links for the latest release (v1.18):
Here are the direct links for the latest release:

1. [**weblaf-1.18.jar**](https://github.com/mgarin/weblaf/releases/download/v1.18/weblaf-1.18.jar) - library jar
2. [**weblaf-src-1.18.zip**](https://github.com/mgarin/weblaf/releases/download/v1.18/weblaf-src-1.18.zip) - project sources zip
Expand Down
4 changes: 3 additions & 1 deletion src/com/alee/examples/WebLookAndFeelDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import com.alee.managers.hotkey.HotkeyManager;
import com.alee.managers.hotkey.HotkeyRunnable;
import com.alee.managers.language.LanguageManager;
import com.alee.managers.notification.NotificationManager;
import com.alee.managers.settings.SettingsManager;
import com.alee.managers.tooltip.TooltipAdapter;
import com.alee.managers.tooltip.TooltipManager;
Expand Down Expand Up @@ -96,11 +97,11 @@ public class WebLookAndFeelDemo extends WebFrame
private SourceViewer sourceViewer;

private WebBreadcrumb locationBreadcrumb;
private WebBreadcrumbToggleButton aboutButton;
private WebBreadcrumbToggleButton demosButton;
private WebBreadcrumbToggleButton sourcesButton;
private WebMemoryBar memoryBar;

@SuppressWarnings ( "UnusedDeclaration" )
private WebButton featureStateLegend;

private static WebLookAndFeelDemo instance = null;
Expand Down Expand Up @@ -605,6 +606,7 @@ public void run ( KeyEvent e )
memoryBar.setPreferredWidth ( memoryBar.getPreferredSize ().width + 20 );
statusBar.addToEnd ( memoryBar );

NotificationManager.setMargin ( 0, 0, statusBar.getPreferredSize ().height, 0 );
return statusBar;
}

Expand Down
2 changes: 2 additions & 0 deletions src/com/alee/examples/content/ExamplesManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import com.alee.examples.groups.list.ListsGroup;
import com.alee.examples.groups.menubar.MenuBarsGroup;
import com.alee.examples.groups.ninepatcheditor.NinePatchEditorGroup;
import com.alee.examples.groups.notification.NotificationsGroup;
import com.alee.examples.groups.optionpane.OptionPanesGroup;
import com.alee.examples.groups.overlay.OverlayGroup;
import com.alee.examples.groups.painter.PaintersGroup;
Expand Down Expand Up @@ -139,6 +140,7 @@ public synchronized static List<ExampleGroup> getExampleGroups ()
exampleGroups.add ( new WindowsGroup () );
exampleGroups.add ( new OptionPanesGroup () );
exampleGroups.add ( new PopupsGroup () );
exampleGroups.add ( new NotificationsGroup () );
exampleGroups.add ( new GalleryGroup () );
exampleGroups.add ( new TransitionsGroup () );
exampleGroups.add ( new ImagesGroup () );
Expand Down
2 changes: 1 addition & 1 deletion src/com/alee/examples/content/ViewTabbedPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class ViewTabbedPane extends WebTabbedPane

public static final String ID_PREFIX = "VTP";

private List<ViewListener> viewListeners = new ArrayList<ViewListener> ();
private List<ViewListener> viewListeners = new ArrayList<ViewListener> ( 1 );

private List<String> ids = new ArrayList<String> ();
private List<JarEntry> data = new ArrayList<JarEntry> ();
Expand Down
4 changes: 2 additions & 2 deletions src/com/alee/examples/groups/desktoppane/tetris/Tetris.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public class Tetris extends JComponent
private static Color bgTop = Color.WHITE;
private static Color bgBottom = new Color ( 223, 223, 223 );

private static List<TickListener> tickListeners = new ArrayList<TickListener> ();
private static List<TetrisListener> tetrisListeners = new ArrayList<TetrisListener> ();
private static List<TickListener> tickListeners = new ArrayList<TickListener> ( 1 );
private static List<TetrisListener> tetrisListeners = new ArrayList<TetrisListener> ( 1 );

// Game state variables
private boolean gameRunning = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/*
* This file is part of WebLookAndFeel library.
*
* WebLookAndFeel library is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* WebLookAndFeel library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with WebLookAndFeel library. If not, see <http://www.gnu.org/licenses/>.
*/

package com.alee.examples.groups.notification;

import com.alee.examples.WebLookAndFeelDemo;
import com.alee.examples.content.DefaultExample;
import com.alee.extended.panel.CenterPanel;
import com.alee.extended.panel.GroupPanel;
import com.alee.extended.time.ClockType;
import com.alee.extended.time.WebClock;
import com.alee.laf.button.WebButton;
import com.alee.managers.notification.NotificationIcon;
import com.alee.managers.notification.NotificationManager;
import com.alee.managers.notification.WebNotificationPopup;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
* Custom notifications example.
*
* @author Mikle Garin
*/

public class CustomNotificationsExample extends DefaultExample
{
/**
* {@inheritDoc}
*/
@Override
public String getTitle ()
{
return "Custom notifications";
}

/**
* {@inheritDoc}
*/
@Override
public String getDescription ()
{
return "Web-styled custom notifications";
}

/**
* {@inheritDoc}
*/
@Override
public Component getPreview ( WebLookAndFeelDemo owner )
{
WebButton notification1 = new WebButton ( "Simple custom content" );
notification1.addActionListener ( new ActionListener ()
{
@Override
public void actionPerformed ( ActionEvent e )
{
final WebNotificationPopup notificationPopup = new WebNotificationPopup ();
notificationPopup.setIcon ( NotificationIcon.question );

final JLabel label = new JLabel ( "Are you sure you want to" );
final WebButton button = new WebButton ( "discard changes?" );
button.setRolloverDecoratedOnly ( true );
button.setDrawFocus ( false );
button.setLeftRightSpacing ( 0 );
button.setBoldFont ();
button.addActionListener ( new ActionListener ()
{
/**
* {@inheritDoc}
*/
@Override
public void actionPerformed ( ActionEvent e )
{
notificationPopup.hidePopup ();
}
} );
final CenterPanel centerPanel = new CenterPanel ( button, false, true );
notificationPopup.setContent ( new GroupPanel ( 2, label, centerPanel ) );

NotificationManager.showNotification ( notificationPopup );
}
} );

WebButton notification2 = new WebButton ( "Limited duration notification" );
notification2.addActionListener ( new ActionListener ()
{
@Override
public void actionPerformed ( ActionEvent e )
{
final WebNotificationPopup notificationPopup = new WebNotificationPopup ();
notificationPopup.setIcon ( NotificationIcon.clock );
notificationPopup.setDisplayTime ( 5000 );

final WebClock clock = new WebClock ();
clock.setClockType ( ClockType.timer );
clock.setTimeLeft ( 6000 );
clock.setTimePattern ( "'This notification will close in' ss 'seconds'" );
notificationPopup.setContent ( new GroupPanel ( clock ) );

NotificationManager.showNotification ( notificationPopup );
clock.start ();
}
} );

return new GroupPanel ( 4, false, notification1, notification2 );
}
}
73 changes: 73 additions & 0 deletions src/com/alee/examples/groups/notification/NotificationsGroup.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* This file is part of WebLookAndFeel library.
*
* WebLookAndFeel library is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* WebLookAndFeel library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with WebLookAndFeel library. If not, see <http://www.gnu.org/licenses/>.
*/

package com.alee.examples.groups.notification;

import com.alee.examples.content.DefaultExampleGroup;
import com.alee.examples.content.Example;

import javax.swing.*;
import java.util.ArrayList;
import java.util.List;

/**
* Notifications usage examples group.
*
* @author Mikle Garin
*/

public class NotificationsGroup extends DefaultExampleGroup
{
/**
* {@inheritDoc}
*/
@Override
public Icon getGroupIcon ()
{
return loadGroupIcon ( "notification.png" );
}

/**
* {@inheritDoc}
*/
@Override
public String getGroupName ()
{
return "Notifications";
}

/**
* {@inheritDoc}
*/
@Override
public String getGroupDescription ()
{
return "Various examples of notifications usage";
}

/**
* {@inheritDoc}
*/
@Override
public List<Example> getGroupExamples ()
{
List<Example> examples = new ArrayList<Example> ();
examples.add ( new TextNotificationsExample () );
examples.add ( new CustomNotificationsExample () );
return examples;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
* This file is part of WebLookAndFeel library.
*
* WebLookAndFeel library is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* WebLookAndFeel library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with WebLookAndFeel library. If not, see <http://www.gnu.org/licenses/>.
*/

package com.alee.examples.groups.notification;

import com.alee.examples.WebLookAndFeelDemo;
import com.alee.examples.content.DefaultExample;
import com.alee.extended.panel.GroupPanel;
import com.alee.laf.button.WebButton;
import com.alee.managers.notification.NotificationIcon;
import com.alee.managers.notification.NotificationManager;
import com.alee.managers.notification.NotificationOption;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
* Text notifications example.
*
* @author Mikle Garin
*/

public class TextNotificationsExample extends DefaultExample
{
/**
* {@inheritDoc}
*/
@Override
public String getTitle ()
{
return "Text notifications";
}

/**
* {@inheritDoc}
*/
@Override
public String getDescription ()
{
return "Web-styled text notifications";
}

/**
* {@inheritDoc}
*/
@Override
public Component getPreview ( WebLookAndFeelDemo owner )
{
WebButton notification1 = new WebButton ( "Simple text notification" );
notification1.addActionListener ( new ActionListener ()
{
@Override
public void actionPerformed ( ActionEvent e )
{
NotificationManager.showNotification ( "Simple notification" );
}
} );

WebButton notification2 = new WebButton ( "Notification with custom icon" );
notification2.addActionListener ( new ActionListener ()
{
@Override
public void actionPerformed ( ActionEvent e )
{
NotificationManager.showNotification ( "Custom notification icon", NotificationIcon.tip.getIcon () );
}
} );

WebButton notification3 = new WebButton ( "Notification with options" );
notification3.addActionListener ( new ActionListener ()
{
@Override
public void actionPerformed ( ActionEvent e )
{
NotificationManager.showNotification ( "Choose one of available options...", NotificationIcon.database.getIcon (),
NotificationOption.apply, NotificationOption.discard );
}
} );

return new GroupPanel ( 4, false, notification1, notification2, notification3 );
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/com/alee/examples/groups/popup/PopupsGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public Icon getGroupIcon ()
@Override
public String getGroupName ()
{
return "Popup";
return "Popups";
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/com/alee/examples/groups/popup/SimplePopupExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void actionPerformed ( ActionEvent e )
}
else
{
popup.showPopup ( showPopup );
popup.showAsPopupMenu ( showPopup );
}
}
} );
Expand Down
Loading

0 comments on commit 299bfc5

Please sign in to comment.