use of org.netxms.ui.eclipse.tools.ColorCache in project netxms by netxms.
the class DefaultMobileLoginForm method createContents.
/* (non-Javadoc)
* @see org.eclipse.jface.window.Window#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
colors = new ColorCache(parent);
Rectangle displayBounds = parent.getDisplay().getPrimaryMonitor().getBounds();
boolean isLandscape = displayBounds.width > displayBounds.height;
System.out.println(">>>> " + displayBounds.width + " x " + displayBounds.height + " DPI=" + parent.getDisplay().getDPI());
// $NON-NLS-1$
final Font headerFont = new Font(parent.getDisplay(), "Verdana", 18, SWT.BOLD);
parent.setBackground(colors.create(255, 255, 255));
// SWT.NO_FOCUS is a workaround for Eclipse/RAP bug 321274
final Canvas content = new Canvas(parent, SWT.NO_FOCUS);
GridLayout layout = new GridLayout();
layout.numColumns = isLandscape ? 2 : 1;
layout.marginWidth = 10;
layout.marginHeight = 10;
layout.horizontalSpacing = 10;
layout.verticalSpacing = 10;
content.setLayout(layout);
GridData gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
gd.horizontalAlignment = SWT.CENTER;
gd.verticalAlignment = SWT.CENTER;
content.setLayoutData(gd);
content.setBackground(parent.getBackground());
Label title = new Label(content, SWT.CENTER);
final String customTitle = BrandingManager.getInstance().getLoginTitle();
title.setText((customTitle != null) ? customTitle : Messages.get().LoginForm_Title);
title.setFont(headerFont);
title.setForeground(colors.create(57, 33, 89));
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = layout.numColumns;
title.setLayoutData(gd);
Image userImage = null;
try {
// $NON-NLS-1$
ImageDescriptor d = ImageDescriptor.createFromURL(new URL("http://127.0.0.1/netxms_login.dat"));
if (d != null)
userImage = d.createImage(false);
} catch (Exception e) {
Activator.logError("Exception while reading custom image", e);
userImage = null;
}
final ImageDescriptor customImage = BrandingManager.getInstance().getLoginTitleImage();
// $NON-NLS-1$
final Image loginImage = (userImage != null) ? userImage : ((customImage != null) ? customImage.createImage() : Activator.getImageDescriptor("icons/login.png").createImage());
Label logo = new Label(content, SWT.NONE);
logo.setImage(loginImage);
logo.setLayoutData(isLandscape ? new GridData(SWT.LEFT, SWT.TOP, false, true) : new GridData(SWT.CENTER, SWT.TOP, true, false));
Composite loginArea = new Composite(content, SWT.NONE);
layout = new GridLayout();
loginArea.setLayout(layout);
gd = new GridData();
gd.widthHint = 300;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
loginArea.setLayoutData(gd);
textLogin = new LabeledText(loginArea, SWT.NONE);
textLogin.setLabel(Messages.get().LoginForm_UserName);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
textLogin.setLayoutData(gd);
textPassword = new LabeledText(loginArea, SWT.NONE, SWT.SINGLE | SWT.BORDER | SWT.PASSWORD);
textPassword.setLabel(Messages.get().LoginForm_Password);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
textPassword.setLayoutData(gd);
Button okButton = new Button(loginArea, SWT.PUSH);
okButton.setText(Messages.get().LoginForm_LoginButton);
okButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
okPressed();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
gd = new GridData();
gd.horizontalAlignment = SWT.RIGHT;
gd.widthHint = WidgetHelper.BUTTON_WIDTH_HINT;
gd.verticalIndent = 5;
okButton.setLayoutData(gd);
content.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent event) {
loginImage.dispose();
headerFont.dispose();
}
});
Label version = new Label(parent, SWT.NONE);
version.setText(String.format(Messages.get().LoginForm_Version, NXCommon.VERSION + " (" + BuildNumber.TEXT + ")"));
version.setBackground(parent.getBackground());
version.setForeground(colors.create(32, 32, 32));
gd = new GridData();
gd.horizontalAlignment = SWT.RIGHT;
gd.verticalAlignment = SWT.BOTTOM;
version.setLayoutData(gd);
getShell().setDefaultButton(okButton);
textLogin.getTextControl().setFocus();
return content;
}
use of org.netxms.ui.eclipse.tools.ColorCache in project netxms by netxms.
the class DefaultLoginForm method createContents.
/* (non-Javadoc)
* @see org.eclipse.jface.window.Window#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
colors = new ColorCache(parent);
parent.setBackground(colors.create(SCREEN_BACKGROUND));
Composite fillerTop = new Composite(parent, SWT.NONE);
fillerTop.setBackground(colors.create(SCREEN_BACKGROUND));
GridData gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = false;
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
gd.heightHint = 100;
fillerTop.setLayoutData(gd);
// SWT.NO_FOCUS is a workaround for Eclipse/RAP bug 321274
final Canvas content = new Canvas(parent, SWT.NO_FOCUS);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginWidth = 10;
layout.marginHeight = 10;
layout.horizontalSpacing = 10;
layout.verticalSpacing = 10;
content.setLayout(layout);
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
gd.horizontalAlignment = SWT.CENTER;
gd.verticalAlignment = SWT.CENTER;
content.setLayoutData(gd);
content.setBackground(colors.create(FORM_BACKGROUND));
final Image userImage = (properties.getProperty("loginFormImage") != null) ? loadUserImage() : null;
final ImageDescriptor customImage = BrandingManager.getInstance().getLoginTitleImage();
// $NON-NLS-1$
final Image loginImage = (userImage != null) ? userImage : ((customImage != null) ? customImage.createImage() : Activator.getImageDescriptor("icons/login.png").createImage());
Label logo = new Label(content, SWT.NONE);
logo.setBackground(colors.create(FORM_BACKGROUND));
logo.setImage(loginImage);
logo.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, false, false));
Composite loginArea = new Composite(content, SWT.NONE);
loginArea.setBackground(colors.create(FORM_BACKGROUND));
layout = new GridLayout();
loginArea.setLayout(layout);
gd = new GridData();
gd.widthHint = 300;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
loginArea.setLayoutData(gd);
textLogin = new LabeledText(loginArea, SWT.NONE);
textLogin.setBackground(colors.create(FORM_BACKGROUND));
textLogin.setLabel(Messages.get().LoginForm_UserName);
textLogin.getTextControl().setData(RWT.CUSTOM_VARIANT, "login");
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
textLogin.setLayoutData(gd);
textPassword = new LabeledText(loginArea, SWT.NONE, SWT.SINGLE | SWT.BORDER | SWT.PASSWORD);
textPassword.setBackground(colors.create(FORM_BACKGROUND));
textPassword.setLabel(Messages.get().LoginForm_Password);
textPassword.getTextControl().setData(RWT.CUSTOM_VARIANT, "login");
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
textPassword.setLayoutData(gd);
Button okButton = new Button(loginArea, SWT.PUSH);
okButton.setText(Messages.get().LoginForm_LoginButton);
okButton.setData(RWT.CUSTOM_VARIANT, "login");
okButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
okPressed();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
gd = new GridData();
gd.horizontalAlignment = SWT.LEFT;
gd.widthHint = WidgetHelper.BUTTON_WIDTH_HINT;
gd.verticalIndent = 5;
okButton.setLayoutData(gd);
final ImageHyperlink setupLink = new ImageHyperlink(loginArea, SWT.NONE);
setupLink.setText(Messages.get().LoginForm_Options);
setupLink.setForeground(colors.create(33, 0, 127));
gd = new GridData();
gd.horizontalAlignment = SWT.RIGHT;
gd.verticalAlignment = SWT.BOTTOM;
gd.grabExcessVerticalSpace = true;
setupLink.setLayoutData(gd);
setupLink.addHyperlinkListener(new HyperlinkAdapter() {
@Override
public void linkEntered(HyperlinkEvent e) {
super.linkEntered(e);
setupLink.setUnderlined(true);
}
@Override
public void linkExited(HyperlinkEvent e) {
super.linkExited(e);
setupLink.setUnderlined(false);
}
@Override
public void linkActivated(HyperlinkEvent e) {
if (advancedSettingsEnabled) {
LoginSettingsDialog dlg = new LoginSettingsDialog(getShell(), properties);
dlg.open();
} else {
MessageDialog.openError(getShell(), Messages.get().LoginForm_Error, Messages.get().LoginForm_AdvOptionsDisabled);
}
}
});
content.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent event) {
loginImage.dispose();
}
});
Composite fillerBottom = new Composite(parent, SWT.NONE);
fillerBottom.setBackground(colors.create(SCREEN_BACKGROUND));
fillerBottom.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
Label version = new Label(parent, SWT.NONE);
version.setText(String.format(Messages.get().LoginForm_Version, NXCommon.VERSION + " (" + BuildNumber.TEXT + ")"));
version.setBackground(parent.getBackground());
version.setForeground(colors.create(VERSION_FOREGROUND));
gd = new GridData();
gd.horizontalAlignment = SWT.RIGHT;
gd.verticalAlignment = SWT.BOTTOM;
version.setLayoutData(gd);
getShell().setDefaultButton(okButton);
textLogin.getTextControl().setFocus();
return content;
}
use of org.netxms.ui.eclipse.tools.ColorCache in project netxms by netxms.
the class ServiceAvailability method createPartControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
final Composite clientArea = new Composite(parent, SWT.NONE);
colors = new ColorCache(clientArea);
GridLayout layout = new GridLayout();
layout.numColumns = 4;
clientArea.setLayout(layout);
dayChart = createChart(clientArea, Messages.get().ServiceAvailability_Today);
weekChart = createChart(clientArea, Messages.get().ServiceAvailability_ThisWeek);
monthChart = createChart(clientArea, Messages.get().ServiceAvailability_ThisMonth);
Canvas legend = new Canvas(clientArea, SWT.NONE);
legend.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
paintLegend(e.gc);
}
});
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
legend.setLayoutData(gd);
listener = new SessionListener() {
@Override
public void notificationHandler(final SessionNotification n) {
if (!clientArea.isDisposed() && (n.getCode() == SessionNotification.OBJECT_CHANGED) && (n.getSubCode() == object.getObjectId())) {
clientArea.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
object = (ServiceContainer) n.getObject();
refresh();
}
});
}
}
};
ConsoleSharedData.getSession().addListener(listener);
}
use of org.netxms.ui.eclipse.tools.ColorCache in project netxms by netxms.
the class StatusDisplayInfo method init.
/**
* Initialize static members. Intended to be called once by library activator.
*/
public static void init(Display display) {
statusText[ObjectStatus.NORMAL.getValue()] = Messages.get().StatusDisplayInfo_Normal;
statusText[ObjectStatus.WARNING.getValue()] = Messages.get().StatusDisplayInfo_Warning;
statusText[ObjectStatus.MINOR.getValue()] = Messages.get().StatusDisplayInfo_Minor;
statusText[ObjectStatus.MAJOR.getValue()] = Messages.get().StatusDisplayInfo_Major;
statusText[ObjectStatus.CRITICAL.getValue()] = Messages.get().StatusDisplayInfo_Critical;
statusText[ObjectStatus.UNKNOWN.getValue()] = Messages.get().StatusDisplayInfo_Unknown;
statusText[ObjectStatus.UNMANAGED.getValue()] = Messages.get().StatusDisplayInfo_Unmanaged;
statusText[ObjectStatus.DISABLED.getValue()] = Messages.get().StatusDisplayInfo_Disabled;
statusText[ObjectStatus.TESTING.getValue()] = Messages.get().StatusDisplayInfo_Testing;
// $NON-NLS-1$
statusImageDesc[ObjectStatus.NORMAL.getValue()] = Activator.getImageDescriptor("icons/status/normal.png");
// $NON-NLS-1$
statusImageDesc[ObjectStatus.WARNING.getValue()] = Activator.getImageDescriptor("icons/status/warning.png");
// $NON-NLS-1$
statusImageDesc[ObjectStatus.MINOR.getValue()] = Activator.getImageDescriptor("icons/status/minor.png");
// $NON-NLS-1$
statusImageDesc[ObjectStatus.MAJOR.getValue()] = Activator.getImageDescriptor("icons/status/major.png");
// $NON-NLS-1$
statusImageDesc[ObjectStatus.CRITICAL.getValue()] = Activator.getImageDescriptor("icons/status/critical.png");
// $NON-NLS-1$
statusImageDesc[ObjectStatus.UNKNOWN.getValue()] = Activator.getImageDescriptor("icons/status/unknown.png");
// $NON-NLS-1$
statusImageDesc[ObjectStatus.UNMANAGED.getValue()] = Activator.getImageDescriptor("icons/status/unmanaged.png");
// $NON-NLS-1$
statusImageDesc[ObjectStatus.DISABLED.getValue()] = Activator.getImageDescriptor("icons/status/disabled.png");
// $NON-NLS-1$
statusImageDesc[ObjectStatus.TESTING.getValue()] = Activator.getImageDescriptor("icons/status/testing.png");
for (int i = 0; i < statusImageDesc.length; i++) statusImage[i] = statusImageDesc[i].createImage();
colorCache = new ColorCache();
updateStatusColors();
}
use of org.netxms.ui.eclipse.tools.ColorCache in project netxms by netxms.
the class AvailabilityChart method createClientArea.
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.widgets.DashboardElement#createClientArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createClientArea(Composite parent) {
Composite clientArea = new Composite(parent, SWT.NONE);
colors = new ColorCache(clientArea);
GridLayout layout = new GridLayout();
layout.numColumns = 4;
clientArea.setLayout(layout);
dayChart = createChart(clientArea, Messages.get().AvailabilityChart_Today);
weekChart = createChart(clientArea, Messages.get().AvailabilityChart_ThisWeek);
monthChart = createChart(clientArea, Messages.get().AvailabilityChart_ThisMonth);
Canvas legend = new Canvas(clientArea, SWT.NONE);
legend.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
paintLegend(e.gc);
}
});
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
legend.setLayoutData(gd);
return clientArea;
}
Aggregations