use of org.openide.util.Lookup in project gephi by gephi.
the class PropertiesBar method getFullScreenIcon.
private JComponent getFullScreenIcon() {
int logoWidth = 27;
int logoHeight = 28;
//fullscreen icon size
if (UIUtils.isAquaLookAndFeel()) {
logoWidth = 34;
}
JPanel c = new JPanel(new BorderLayout());
c.setBackground(Color.WHITE);
JButton fullScreenButton = new JButton();
fullScreenButton.setIcon(new ImageIcon(getClass().getResource("/org/gephi/desktop/tools/gephilogo_std.png")));
fullScreenButton.setRolloverEnabled(true);
fullScreenButton.setRolloverIcon(new ImageIcon(getClass().getResource("/org/gephi/desktop/tools/gephilogo_glow.png")));
fullScreenButton.setToolTipText(NbBundle.getMessage(PropertiesBar.class, "PropertiesBar.fullScreenButton.tooltip"));
fullScreenButton.setBorderPainted(false);
fullScreenButton.setContentAreaFilled(false);
fullScreenButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
fullScreenButton.setBorder(BorderFactory.createEmptyBorder());
fullScreenButton.setPreferredSize(new Dimension(logoWidth, logoHeight));
fullScreenButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Lookup lookup = Lookups.forPath("org-gephi-desktop-tools/Actions/ToggleFullScreenAction");
for (Action a : lookup.lookupAll(Action.class)) {
a.actionPerformed(null);
}
}
});
c.add(fullScreenButton, BorderLayout.CENTER);
return c;
}
use of org.openide.util.Lookup in project ACS by ACS-Community.
the class ToolsAction method generate.
/** Implementation method that regenerates the items in the menu or
* in the array.
*
* @param forMenu true if Presenter.Menu should be used false if Presenter.Popup
* @param list (can be null)
*/
private static List generate(Action toolsAction, boolean forMenu) {
ActionManager am = (ActionManager) Lookup.getDefault().lookup(ActionManager.class);
SystemAction[] actions = am.getContextActions();
List list = new ArrayList(actions.length);
boolean separator = false;
// flag to prevent adding separator before actual menu items
boolean firstItemAdded = false;
// Get action context.
Lookup lookup;
if (toolsAction instanceof Lookup.Provider) {
lookup = ((Lookup.Provider) toolsAction).getLookup();
} else {
lookup = null;
}
for (int i = 0; i < actions.length; i++) {
Action a;
// Retrieve context sensitive action instance if possible.
if (lookup != null && actions[i] instanceof ContextAwareAction) {
a = ((ContextAwareAction) actions[i]).createContextAwareInstance(lookup);
} else {
a = actions[i];
}
if (a == null) {
if (firstItemAdded)
separator = true;
} else if (forMenu) {
if (a instanceof Presenter.Menu && a.isEnabled()) {
if (separator) {
list.add(null);
separator = false;
}
JMenuItem mi = ((Presenter.Menu) a).getMenuPresenter();
list.add(mi);
firstItemAdded = true;
}
} else if (a instanceof Presenter.Popup && a.isEnabled()) {
if (separator) {
list.add(null);
separator = false;
}
JMenuItem mi = ((Presenter.Popup) a).getPopupPresenter();
list.add(mi);
firstItemAdded = true;
}
}
return list;
}
use of org.openide.util.Lookup in project ACS by ACS-Community.
the class SimpleLookup method lookup.
public Object lookup(Class clazz) {
log.debug("looking up " + clazz.getName());
// else
if (clazz.getName().indexOf("Registry") != -1) {
WindowManager wm = WindowManager.getDefault();
if (wm != null && wm instanceof DummyWindowManager) {
return ((DummyWindowManager) wm).registry();
} else {
log.warn("unable to return registry");
}
} else if (clazz.getName().indexOf("DialogDisplayer") != -1) {
if (dialog == null) {
dialog = new NbDialogDisplayer();
}
return dialog;
} else if (clazz.getName().indexOf("NodeOp") != -1) {
if (nodeOp == null) {
nodeOp = new NbNodeOperation();
}
return nodeOp;
}
// this can be further tuned to better performance
Lookup.Item item = lookupItem(new Lookup.Template(clazz));
return item == null ? null : item.getInstance();
}
use of org.openide.util.Lookup in project ACS by ACS-Community.
the class TopComponent method getLookup.
/** Gets lookup which represents context of this component. By default
* the lookup delegates to result of <code>getActivatedNodes</code>
* method and result of this component <code>ActionMap</code> delegate.
*
* @return a lookup with designates context of this component
* @see org.openide.util.ContextAwareAction
* @see org.openide.util.Utilities#actionsToPopup(Action[], Lookup)
* @since 3.29
*/
public Lookup getLookup() {
synchronized (defaultLookupLock) {
Object l = defaultLookupRef.get();
if (l instanceof Lookup) {
return (Lookup) l;
}
Lookup lookup = new ProxyLookup(new Lookup[] { // Lookup of activated nodes.
new DefaultTopComponentLookup(this), // Action map lookup.
Lookups.singleton(new DelegateActionMap(this)) });
defaultLookupRef = new java.lang.ref.WeakReference(lookup);
return lookup;
}
}
Aggregations