use of org.netxms.ui.eclipse.tools.ImageCache in project netxms by netxms.
the class AlarmComments method createPartControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
imageCache = new ImageCache();
toolkit = new FormToolkit(parent.getDisplay());
form = toolkit.createScrolledForm(parent);
TableWrapLayout layout = new TableWrapLayout();
layout.numColumns = 1;
form.getBody().setLayout(layout);
createAlarmDetailsSection();
createEditorsSection();
createActions();
contributeToActionBars();
refresh();
}
use of org.netxms.ui.eclipse.tools.ImageCache in project netxms by netxms.
the class ObjectToolsDynamicMenu method fill.
/* (non-Javadoc)
* @see org.eclipse.jface.action.ContributionItem#fill(org.eclipse.swt.widgets.Menu, int)
*/
@Override
public void fill(Menu menu, int index) {
Object selection = evalService.getCurrentState().getVariable(ISources.ACTIVE_MENU_SELECTION_NAME);
if ((selection == null) || !(selection instanceof IStructuredSelection))
return;
final Set<ObjectContext> nodes = buildNodeSet((IStructuredSelection) selection);
final Menu toolsMenu = new Menu(menu);
final ImageCache imageCache = new ImageCache();
toolsMenu.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
imageCache.dispose();
}
});
ObjectTool[] tools = ObjectToolsCache.getInstance().getTools();
Arrays.sort(tools, new Comparator<ObjectTool>() {
@Override
public int compare(ObjectTool arg0, ObjectTool arg1) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
return arg0.getName().replace("&", "").compareToIgnoreCase(arg1.getName().replace("&", ""));
}
});
Map<String, Menu> menus = new HashMap<String, Menu>();
int added = 0;
for (int i = 0; i < tools.length; i++) {
boolean enabled = (tools[i].getFlags() & ObjectTool.DISABLED) == 0;
if (enabled && ObjectToolExecutor.isToolAllowed(tools[i], nodes) && ObjectToolExecutor.isToolApplicable(tools[i], nodes)) {
// $NON-NLS-1$
String[] path = tools[i].getName().split("\\-\\>");
Menu rootMenu = toolsMenu;
for (int j = 0; j < path.length - 1; j++) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
final String key = rootMenu.hashCode() + "@" + path[j].replace("&", "");
Menu currMenu = menus.get(key);
if (currMenu == null) {
currMenu = new Menu(rootMenu);
MenuItem item = new MenuItem(rootMenu, SWT.CASCADE);
item.setText(path[j]);
item.setMenu(currMenu);
menus.put(key, currMenu);
}
rootMenu = currMenu;
}
final MenuItem item = new MenuItem(rootMenu, SWT.PUSH);
item.setText(path[path.length - 1]);
ImageDescriptor icon = ObjectToolsCache.getInstance().findIcon(tools[i].getId());
if (icon != null)
item.setImage(imageCache.add(icon));
item.setData(tools[i]);
item.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
ObjectToolExecutor.execute(nodes, (ObjectTool) item.getData());
}
});
added++;
}
}
if (added > 0) {
MenuItem toolsMenuItem = new MenuItem(menu, SWT.CASCADE, index);
toolsMenuItem.setText(Messages.get().ObjectToolsDynamicMenu_TopLevelLabel);
toolsMenuItem.setMenu(toolsMenu);
} else {
toolsMenu.dispose();
}
}
use of org.netxms.ui.eclipse.tools.ImageCache in project netxms by netxms.
the class DateFieldEditor method createContent.
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.reporter.widgets.FieldEditor#createContent(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContent(Composite parent) {
final ImageCache imageCache = new ImageCache(this);
final Composite content = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 4;
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.horizontalSpacing = WidgetHelper.INNER_SPACING;
layout.makeColumnsEqualWidth = true;
content.setLayout(layout);
Calendar dateTime = Calendar.getInstance();
try {
dateTime.setTime(new Date(Long.parseLong(parameter.getDefaultValue()) * 1000));
} catch (NumberFormatException e) {
dateTime.setTime(new Date());
}
final String[] dateElementNames = { Messages.get().DateFieldEditor_Year, Messages.get().DateFieldEditor_Month, Messages.get().DateFieldEditor_Day };
dateElements = new Combo[dateElementNames.length];
for (int idx = 0; idx < dateElementNames.length; idx++) {
Combo cb = WidgetHelper.createLabeledCombo(content, SWT.BORDER, dateElementNames[idx], WidgetHelper.DEFAULT_LAYOUT_DATA);
cb.setText(getDateTimeText(idx, dateTime));
// $NON-NLS-1$
cb.add("current");
// $NON-NLS-1$
cb.add("previous");
// $NON-NLS-1$
cb.add("next");
dateElements[idx] = cb;
}
final ImageHyperlink link = toolkit.createImageHyperlink(content, SWT.NONE);
// $NON-NLS-1$
link.setImage(imageCache.add(Activator.getImageDescriptor("icons/calendar.png")));
link.setToolTipText(Messages.get().DateFieldEditor_Calendar);
link.addHyperlinkListener(new HyperlinkAdapter() {
@Override
public void linkActivated(HyperlinkEvent e) {
createPopupCalendar(link);
}
});
GridData gd = new GridData();
gd.verticalAlignment = SWT.BOTTOM;
gd.horizontalAlignment = SWT.LEFT;
link.setLayoutData(gd);
return content;
}
use of org.netxms.ui.eclipse.tools.ImageCache in project netxms by netxms.
the class AlarmDetails method createPartControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
imageCache = new ImageCache();
scroller = new ScrolledComposite(parent, SWT.V_SCROLL);
scroller.setExpandVertical(true);
formContainer = new Composite(scroller, SWT.NONE);
GridLayout containerLayout = new GridLayout();
containerLayout.marginHeight = 0;
containerLayout.marginWidth = 0;
formContainer.setLayout(containerLayout);
scroller.setContent(formContainer);
scroller.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
Rectangle r = scroller.getClientArea();
Point formSize = formContainer.computeSize(r.width, SWT.DEFAULT);
formContainer.setSize(r.width, formSize.y);
scroller.setMinHeight(formSize.y);
}
});
toolkit = new FormToolkit(parent.getDisplay());
form = toolkit.createForm(formContainer);
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
form.setLayoutData(gd);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
form.getBody().setLayout(layout);
createAlarmDetailsSection();
createEventsSection();
createCommentsSection();
createDataSection();
createActions();
contributeToActionBars();
refresh();
}
Aggregations