Example usage for org.eclipse.jface.dialogs MessageDialog openWarning

List of usage examples for org.eclipse.jface.dialogs MessageDialog openWarning

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs MessageDialog openWarning.

Prototype

public static void openWarning(Shell parent, String title, String message) 

Source Link

Document

Convenience method to open a standard warning dialog.

Usage

From source file:com.clustercontrol.notify.mail.view.action.MailTemplateDeleteAction.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    // ???/*from ww  w.ja  va2 s . c o  m*/
    this.viewPart = HandlerUtil.getActivePart(event);
    MailTemplateListView view = null;
    try {
        view = (MailTemplateListView) this.viewPart.getAdapter(MailTemplateListView.class);
    } catch (Exception e) {
        m_log.info("execute " + e.getMessage());
        return null;
    }

    if (view == null) {
        m_log.info("execute: view is null");
        return null;
    }

    MailTemplateListComposite composite = (MailTemplateListComposite) view.getListComposite();
    StructuredSelection selection = (StructuredSelection) composite.getTableViewer().getSelection();

    List<?> list = (List<?>) selection.toList();

    Map<String, List<String>> deleteMap = new ConcurrentHashMap<String, List<String>>();
    int size = 0;
    StringBuffer buf = new StringBuffer();
    if (list != null && list.size() > 0) {
        for (Object obj : list) {
            List<?> objList = (List<?>) obj;
            String managerName = (String) objList.get(GetMailTemplateListTableDefine.MANAGER_NAME);
            if (deleteMap.get(managerName) != null) {
                continue;
            }
            deleteMap.put(managerName, new ArrayList<String>());
        }
        for (Object obj : list) {
            List<?> objList = (List<?>) obj;
            String mailTemplateId = (String) objList.get(NotifyTableDefineNoCheckBox.NOTIFY_ID);
            String managerName = (String) objList.get(NotifyTableDefineNoCheckBox.MANAGER_NAME);
            if (size > 0) {
                buf.append(", ");
            }
            buf.append(mailTemplateId);
            deleteMap.get(managerName).add(mailTemplateId);
            size++;
        }
    }

    String[] args = { buf.toString() };

    // ?????????
    if (size == 0) {
        MessageDialog.openWarning(null, Messages.getString("warning"),
                Messages.getString("message.notify.mail.8"));
        return null;
    }

    if (MessageDialog.openConfirm(null, Messages.getString("confirmed"),
            Messages.getString("message.notify.mail.7", args)) == false) {
        return null;
    }

    boolean result = false;
    for (Map.Entry<String, List<String>> entry : deleteMap.entrySet()) {
        String managerName = entry.getKey();
        for (String mailTemplateId : entry.getValue()) {
            result = result | new DeleteMailTemplate().delete(managerName, mailTemplateId);
        }
    }

    if (result) {
        composite.update();
    }

    return null;
}

From source file:com.clustercontrol.notify.mail.view.action.MailTemplateModifyAction.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    // ???//from ww w .java2  s .  c o m
    this.viewPart = HandlerUtil.getActivePart(event);
    MailTemplateListView view = null;
    try {
        view = (MailTemplateListView) this.viewPart.getAdapter(MailTemplateListView.class);
    } catch (Exception e) {
        m_log.info("execute " + e.getMessage());
        return null;
    }

    if (view == null) {
        m_log.info("execute: view is null");
        return null;
    }

    MailTemplateListComposite composite = (MailTemplateListComposite) view.getListComposite();
    WidgetTestUtil.setTestId(this, null, composite);
    StructuredSelection selection = (StructuredSelection) composite.getTableViewer().getSelection();

    List<?> list = (List<?>) selection.getFirstElement();
    String managerName = null;
    String mailTemplateId = null;
    if (list != null && list.size() > 0) {
        managerName = (String) list.get(GetMailTemplateListTableDefine.MANAGER_NAME);
        mailTemplateId = (String) list.get(GetMailTemplateListTableDefine.MAIL_TEMPLATE_ID);
    }

    Table table = composite.getTableViewer().getTable();
    WidgetTestUtil.setTestId(this, null, table);

    // ???????
    if (mailTemplateId != null) {
        MailTemplateCreateDialog dialog = new MailTemplateCreateDialog(view.getListComposite().getShell(),
                managerName, mailTemplateId, PropertyDefineConstant.MODE_MODIFY);
        if (dialog.open() == IDialogConstants.OK_ID) {
            int selectIndex = table.getSelectionIndex();
            composite.update();
            table.setSelection(selectIndex);
        }
    } else {
        MessageDialog.openWarning(null, Messages.getString("warning"),
                Messages.getString("message.notify.mail.8"));
    }
    return null;
}

From source file:com.clustercontrol.notify.view.action.NotifyCopyAction.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    // ???//from   w  ww . j  a  va2s . c o  m
    this.viewPart = HandlerUtil.getActivePart(event);
    NotifyListView view = null;
    try {
        view = (NotifyListView) this.viewPart.getAdapter(NotifyListView.class);
    } catch (Exception e) {
        m_log.info("execute " + e.getMessage());
        return null;
    }

    if (view == null) {
        m_log.info("execute: view is null");
        return null;
    }

    NotifyListComposite composite = (NotifyListComposite) view.getListComposite();
    WidgetTestUtil.setTestId(this, null, composite);
    StructuredSelection selection = (StructuredSelection) composite.getTableViewer().getSelection();

    List<?> list = (List<?>) selection.getFirstElement();
    String managerName = null;
    String notifyId = null;
    Integer notifyType = null;
    if (list != null && list.size() > 0) {
        managerName = (String) list.get(NotifyTableDefineNoCheckBox.MANAGER_NAME);
        notifyId = (String) list.get(NotifyTableDefineNoCheckBox.NOTIFY_ID);
        notifyType = (Integer) list.get(NotifyTableDefineNoCheckBox.NOTIFY_TYPE);
    }

    Table table = composite.getTableViewer().getTable();
    WidgetTestUtil.setTestId(this, null, table);

    // ???????
    if (notifyId != null && notifyType != null) {
        Shell shell = view.getListComposite().getShell();
        if (openDialog(shell, managerName, notifyId, notifyType) == IDialogConstants.OK_ID) {
            int selectIndex = table.getSelectionIndex();
            composite.update();
            table.setSelection(selectIndex);
        }
    } else {
        MessageDialog.openWarning(null, Messages.getString("warning"), Messages.getString("message.notify.8"));
    }
    return null;
}

From source file:com.clustercontrol.notify.view.action.NotifyDeleteAction.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    // ???/*from   w  w  w .ja v a 2s .c  om*/
    this.viewPart = HandlerUtil.getActivePart(event);
    NotifyListView view = null;
    try {
        view = (NotifyListView) this.viewPart.getAdapter(NotifyListView.class);
    } catch (Exception e) {
        m_log.info("execute " + e.getMessage());
        return null;
    }

    if (view == null) {
        m_log.info("execute: view is null");
        return null;
    }

    NotifyListComposite composite = (NotifyListComposite) view.getListComposite();
    StructuredSelection selection = (StructuredSelection) composite.getTableViewer().getSelection();
    List<?> list = (List<?>) selection.toList();

    Map<String, List<String>> deleteMap = new ConcurrentHashMap<String, List<String>>();
    int size = 0;
    if (list != null && list.size() > 0) {
        for (Object obj : list) {
            List<?> objList = (List<?>) obj;
            String managerName = (String) objList.get(NotifyTableDefineNoCheckBox.MANAGER_NAME);
            if (deleteMap.get(managerName) != null) {
                continue;
            }
            deleteMap.put(managerName, new ArrayList<String>());
        }
        String notifyId = null;
        for (Object obj : list) {
            List<?> objList = (List<?>) obj;
            notifyId = (String) objList.get(NotifyTableDefineNoCheckBox.NOTIFY_ID);
            String managerName = (String) objList.get(NotifyTableDefineNoCheckBox.MANAGER_NAME);
            deleteMap.get(managerName).add(notifyId);
            size++;
        }

        String[] args = new String[1];
        String msg = null;
        if (size > 0) {
            if (size == 1) {
                args[0] = notifyId;
                msg = "message.notify.7";
            } else {
                args[0] = Integer.toString(size);
                msg = "message.notify.51";
            }
        }

        // ?????????
        DeleteNotify deleteNotify = new DeleteNotify();

        boolean check = true;
        for (Map.Entry<String, List<String>> map : deleteMap.entrySet()) {
            String managerName = map.getKey();
            // ?ID?????????
            if (deleteNotify.useCheck(managerName, map.getValue()) != Window.OK) {
                check = false;
            }
        }

        if (check) {

            if (MessageDialog.openConfirm(null, Messages.getString("confirmed"),
                    Messages.getString(msg, args)) == false) {

                return null;
            }

            boolean result = false;
            for (Map.Entry<String, List<String>> map : deleteMap.entrySet()) {
                result = result | deleteNotify.delete(map.getKey(), map.getValue());
            }
            if (result) {
                composite.update();
            }
        }
    } else {
        MessageDialog.openWarning(null, Messages.getString("warning"), Messages.getString("message.notify.9"));
    }
    return null;
}

From source file:com.clustercontrol.repository.dialog.NodeCreateDialog.java

License:Open Source License

private void setAutoButton() {
    this.buttonAuto = new Button(groupAuto, SWT.PUSH | SWT.RIGHT);
    WidgetTestUtil.setTestId(this, "auto", buttonAuto);
    this.buttonAuto.setText(" Search ");
    GridData gridData = new GridData();
    gridData.horizontalIndent = 30;//from   w  ww .j  a  va2 s  .com
    this.buttonAuto.setLayoutData(gridData);
    this.buttonAuto.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            try {
                String ipAddressString = ipAddressBox.getText();

                // IP?
                InetAddress address = InetAddress.getByName(ipAddressString);

                if (address instanceof Inet4Address) {

                    //IPv4?????String?
                    if (!ipAddressString.matches(".{1,3}?\\..{1,3}?\\..{1,3}?\\..{1,3}?")) {
                        MessageDialog.openWarning(getShell(), "Warning",
                                Messages.getString("message.repository.37"));
                        return;
                    }

                } else if (address instanceof Inet6Address) {
                    //IPv6????String???
                } else {
                    MessageDialog.openWarning(getShell(), "Warning",
                            Messages.getString("message.repository.37"));
                    return;
                }

                String ipAddress = ipAddressBox.getText();
                Integer port = Integer.parseInt(portBox.getText());
                String community = communityBox.getText();
                Integer version = versionBox.getSelectionIndex() == INDEX_VERSION_BOX_2
                        ? SnmpVersionConstant.TYPE_V3
                        : versionBox.getSelectionIndex();
                String securityLevel = securityLevelBox == null || securityLevelBox.isDisposed() ? null
                        : securityLevelBox.getText();
                String user = userBox == null || userBox.isDisposed() ? null : userBox.getText();
                String authPassword = authPassBox == null || authPassBox.isDisposed() ? null
                        : authPassBox.getText();
                String privPassword = privPassBox == null || privPassBox.isDisposed() ? null
                        : privPassBox.getText();
                String authProtocol = authProtocolBox == null || authProtocolBox.isDisposed() ? null
                        : authProtocolBox.getText();
                String privProtocol = privProtocolBox == null || privProtocolBox.isDisposed() ? null
                        : privProtocolBox.getText();

                Property propertySNMP = null;
                NodeInfo nodeInfo = null;

                if (isModifyDialog) {
                    NodeInfoDeviceSearch nodeSnmp = getNodeInfoBySNMP(
                            NodeCreateDialog.this.m_managerComposite.getText(), ipAddress, port, community,
                            version, PropertyDefineConstant.MODE_MODIFY, facilityId, securityLevel, user,
                            authPassword, privPassword, authProtocol, privProtocol);

                    List<DeviceSearchMessageInfo> list = nodeSnmp.getDeviceSearchMessageInfo();
                    if (list != null && list.size() > 0) {
                        DeviceSearchDialog dialog = new DeviceSearchDialog(getShell(), list);
                        dialog.open();
                    }

                    nodeInfo = nodeSnmp.getNodeInfo();

                    propertySNMP = NodePropertyUtil.node2property(m_managerComposite.getText(), nodeInfo,
                            PropertyDefineConstant.MODE_MODIFY, Locale.getDefault());
                    /*
                     * ?Device Search???????
                     */
                    // ????(basicInformation)
                    for (Property propertyObj : PropertyUtil.getProperty(propertyOld,
                            NodeConstant.BASIC_INFORMATION)) {
                        Property p = propertyObj;
                        p.getParent().removeChildren(p);
                    }
                    // ??(basicInformation)
                    for (Property propertyObj : PropertyUtil.getProperty(propertySNMP,
                            NodeConstant.BASIC_INFORMATION)) {
                        Property p = propertyObj;
                        propertyOld.addChildren(p);
                    }

                    /*
                     * ??????????????????????
                     * ??????????
                     */
                    {
                        Property p = null;
                        p = (Property) PropertyUtil.getProperty(propertyOld, NodeConstant.JOB).get(0);
                        propertyOld.removeChildren(p);
                        propertyOld.addChildren(p);
                        p = (Property) PropertyUtil.getProperty(propertyOld, NodeConstant.SERVICE).get(0);
                        propertyOld.removeChildren(p);
                        propertyOld.addChildren(p);
                    }

                    // ????(device)
                    for (Property propertyObj : PropertyUtil.getProperty(propertyOld, NodeConstant.DEVICE)) {
                        Property p = propertyObj;
                        p.getParent().removeChildren(p);
                    }
                    // ??(device)
                    for (Property propertyObj : PropertyUtil.getProperty(propertySNMP, NodeConstant.DEVICE)) {
                        Property p = propertyObj;
                        propertyOld.addChildren(p);
                    }

                    /*
                     * ??????????????????????
                     * ?????????
                     */
                    {
                        Property p = null;
                        p = (Property) PropertyUtil.getProperty(propertyOld, NodeConstant.CLOUD_MANAGEMENT)
                                .get(0);
                        propertyOld.removeChildren(p);
                        propertyOld.addChildren(p);
                        p = (Property) PropertyUtil.getProperty(propertyOld, NodeConstant.NODE_VARIABLE).get(0);
                        propertyOld.removeChildren(p);
                        propertyOld.addChildren(p);
                        p = (Property) PropertyUtil.getProperty(propertyOld, NodeConstant.MAINTENANCE).get(0);
                        propertyOld.removeChildren(p);
                        propertyOld.addChildren(p);
                        p = (Property) PropertyUtil.getProperty(propertyOld, NodeConstant.CREATE_TIME).get(0);
                        propertyOld.removeChildren(p);
                        propertyOld.addChildren(p);
                        p = (Property) PropertyUtil.getProperty(propertyOld, NodeConstant.CREATOR_NAME).get(0);
                        propertyOld.removeChildren(p);
                        propertyOld.addChildren(p);
                        p = (Property) PropertyUtil.getProperty(propertyOld, NodeConstant.MODIFY_TIME).get(0);
                        propertyOld.removeChildren(p);
                        propertyOld.addChildren(p);
                        p = (Property) PropertyUtil.getProperty(propertyOld, NodeConstant.MODIFIER_NAME).get(0);
                        propertyOld.removeChildren(p);
                        propertyOld.addChildren(p);

                        // ???????
                        ArrayList<Property> oArray = PropertyUtil.getProperty(propertyOld, NodeConstant.NOTE);
                        for (Property o : oArray) {
                            propertyOld.removeChildren(o);
                            propertyOld.addChildren(o);
                        }
                    }
                    propertySheet.setInput(propertyOld);
                } else {
                    NodeInfoDeviceSearch nodeSnmp = getNodeInfoBySNMP(
                            NodeCreateDialog.this.m_managerComposite.getText(), ipAddress, port, community,
                            version, PropertyDefineConstant.MODE_ADD, null, securityLevel, user, authPassword,
                            privPassword, authProtocol, privProtocol);
                    if (nodeSnmp != null) {
                        nodeInfo = nodeSnmp.getNodeInfo();

                        propertySNMP = NodePropertyUtil.node2property(m_managerComposite.getText(), nodeInfo,
                                PropertyDefineConstant.MODE_ADD, Locale.getDefault());
                        propertySheet.setInput(propertySNMP);
                    }
                }

                // ??
                expand();
                update();

            } catch (NumberFormatException e1) {
                // port?????
                MessageDialog.openWarning(getShell(), "Warning", Messages.getString("message.repository.38"));

            } catch (UnknownHostException e2) {
                // IP????
                MessageDialog.openWarning(getShell(), "Warning", Messages.getString("message.repository.37"));
            }
        }
    });
}

From source file:com.clustercontrol.repository.dialog.NodeCreateDialog.java

License:Open Source License

/**
 *SNMP??????<BR>/*  www  .  j  ava 2s.co  m*/
 *
 * @param pollingData SNMP?????IP??
 * @param mode ??
 * @return ?
 */
private static NodeInfoDeviceSearch getNodeInfoBySNMP(String managerName, String ipAddress, int port,
        String community, int version, int mode, String facilityID, String securityLevel, String user,
        String authPassword, String privPassword, String authProtocol, String privProtocol) {

    try {
        RepositoryEndpointWrapper wrapper = RepositoryEndpointWrapper.getWrapper(managerName);
        NodeInfoDeviceSearch nodeSnmp = wrapper.getNodePropertyBySNMP(ipAddress, port, community, version,
                facilityID, securityLevel, user, authPassword, privPassword, authProtocol, privProtocol);
        NodeInfo nodeInfo = nodeSnmp.getNodeInfo();
        m_log.info("snmp2 " + nodeInfo.getNodeFilesystemInfo().size());
        NodePropertyUtil.setDefaultNode(nodeInfo);
        return nodeSnmp;
    } catch (InvalidRole_Exception e) {
        MessageDialog.openInformation(null, Messages.getString("message"),
                Messages.getString("message.accesscontrol.16"));
    } catch (SnmpResponseError_Exception e) {
        MessageDialog.openWarning(null, Messages.getString("message"), Messages.getString("message.snmp.12"));
    } catch (Exception e) {
        m_log.warn("GetNodePropertyBySNMP(), " + HinemosMessage.replace(e.getMessage()), e);
        MessageDialog.openError(null, Messages.getString("failed"),
                Messages.getString("message.hinemos.failure.unexpected") + ", "
                        + HinemosMessage.replace(e.getMessage()));
    }
    return null;
}

From source file:com.clustercontrol.repository.view.action.ProgramExecutionAction.java

License:Open Source License

/**
 * @see org.eclipse.core.commands.IHandler#execute
 *//*from w ww.j  av a  2 s.com*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    this.viewPart = HandlerUtil.getActivePart(event);

    // ??????ID?
    NodeListView view = null;
    try {
        view = (NodeListView) this.viewPart.getAdapter(NodeListView.class);
    } catch (Exception e) {
        m_log.info("execute " + e.getMessage());
        return null;
    }

    if (view == null) {
        m_log.info("execute: view is null");
        return null;
    }

    StructuredSelection selection = (StructuredSelection) view.getComposite().getTableViewer().getSelection();

    List<?> list = (List<?>) selection.getFirstElement();

    if (list == null) {
        return null;
    }

    String managerName = (String) list.get(GetNodeListTableDefine.MANAGER_NAME);
    String facilityId = (String) list.get(GetNodeListTableDefine.FACILITY_ID);

    if (facilityId == null) {
        return null;
    }

    // ?
    String execProg = ClusterControlPlugin.getDefault().getPreferenceStore()
            .getString(RepositoryPreferencePage.P_PROGRAM_EXECUTION);

    // ??
    if (execProg.equals("")) {
        MessageDialog.openWarning(null, Messages.getString("warning"),
                Messages.getString("message.repository.49"));
        return null;
    }

    // ???????#?????
    if (execProg.indexOf("#") != -1) {
        try {
            // ????????????
            RepositoryEndpointWrapper wrapper = RepositoryEndpointWrapper.getWrapper(managerName);
            execProg = wrapper.replaceNodeVariable(facilityId, execProg);
        } catch (InvalidRole_Exception e) {
            // ??????
            MessageDialog.openInformation(null, Messages.getString("message"),
                    Messages.getString("message.accesscontrol.16"));
        } catch (Exception e) {
            m_log.warn("run(), " + e.getMessage(), e);
            MessageDialog.openError(null, Messages.getString("failed"),
                    Messages.getString("message.hinemos.failure.unexpected") + ", "
                            + HinemosMessage.replace(e.getMessage()));
        }
    }

    // ?????
    String[] args = null;
    try {
        String user = System.getProperty("user.name");
        args = CommandCreator.createCommand(user, execProg, PlatformType.WINDOWS, false);
    } catch (HinemosUnknown e) {
        m_log.warn("run(), " + e.getMessage(), e);
        MessageDialog.openError(null, Messages.getString("failed"),
                Messages.getString("message.hinemos.failure.unexpected") + ", "
                        + HinemosMessage.replace(e.getMessage()));
    }

    StringBuffer message = new StringBuffer();
    for (String arg : args) {
        message.append(arg + " ");
    }

    String messageStr = message.toString();
    if (MessageDialog.openConfirm(null, Messages.getString("confirmed"),
            Messages.getString("message.repository.46", new String[] { messageStr }))) {

        // ?
        m_log.debug("program execution start : " + messageStr);
        try {
            new CommandExecutor(args).execute();
        } catch (Exception e) {
            MessageDialog.openError(null, Messages.getString("failed"),
                    Messages.getString("message.repository.48") + ", "
                            + HinemosMessage.replace(e.getMessage()));
        }
    }
    return null;
}

From source file:com.clustercontrol.snmptrap.composite.TrapDefineListComposite.java

License:Open Source License

/**
 * ?????/*from  ww w  . j  a  va2s  .  c o  m*/
 */
protected void initialize() {
    GridLayout layout = new GridLayout(1, true);
    this.setLayout(layout);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.numColumns = MAX_COLUMN;

    //????
    Label label = null;

    // 
    Group groupFilter = new Group(this, SWT.NONE);
    WidgetTestUtil.setTestId(this, "filter", groupFilter);
    layout = new GridLayout(1, true);
    layout.marginWidth = 5;
    layout.marginHeight = 5;
    layout.numColumns = MAX_COLUMN;
    groupFilter.setLayout(layout);
    GridData gridData = new GridData();
    gridData.horizontalSpan = MAX_COLUMN;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    groupFilter.setLayoutData(gridData);
    groupFilter.setText(Messages.getString("filter") + " : ");

    /*
     * MIB
     */
    // 
    label = new Label(groupFilter, SWT.NONE);
    WidgetTestUtil.setTestId(this, "mib", label);
    gridData = new GridData();
    gridData.horizontalSpan = WIDTH_TITLE;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    label.setLayoutData(gridData);
    label.setText(Messages.getString("mib") + " : ");
    // 
    this.cmbMib = new Combo(groupFilter, SWT.READ_ONLY | SWT.MULTI | SWT.V_SCROLL);
    WidgetTestUtil.setTestId(this, "mib", cmbMib);
    gridData = new GridData();
    gridData.horizontalSpan = MAX_COLUMN - WIDTH_TITLE - 3;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.heightHint = 30;
    this.cmbMib.setLayoutData(gridData);
    this.cmbMib.setVisibleItemCount(10);
    // MIB?
    this.cmbMib.add("");
    this.cmbMib.select(0);
    this.cmbMib.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            //?
            update();
        }
    });

    // Utility???????
    if (true) {
        label = new Label(groupFilter, SWT.NONE);
        WidgetTestUtil.setTestId(this, null, label);
        gridData = new GridData();
        gridData.horizontalSpan = 3;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        label.setLayoutData(gridData);
    }

    /*
     * 
     */
    // 
    label = new Label(groupFilter, SWT.NONE);
    WidgetTestUtil.setTestId(this, "trapname", label);
    gridData = new GridData();
    gridData.horizontalSpan = WIDTH_TITLE;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    label.setLayoutData(gridData);
    label.setText(Messages.getString("trap.name") + " : ");
    // 
    this.txtFilter = new Text(groupFilter, SWT.BORDER | SWT.LEFT);
    WidgetTestUtil.setTestId(this, "filter", txtFilter);
    gridData = new GridData();
    gridData.horizontalSpan = 10;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    this.txtFilter.setLayoutData(gridData);
    this.txtFilter.addVerifyListener(new StringVerifyListener(DataRangeConstant.VARCHAR_256));
    // 
    this.btnClearFilter = new Button(groupFilter, SWT.NONE);
    WidgetTestUtil.setTestId(this, "clearfilter", btnClearFilter);
    this.btnClearFilter.setText(Messages.getString("clear"));
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    this.btnClearFilter.setLayoutData(gridData);
    this.btnClearFilter.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            txtFilter.setText("");
            update();
        }
    });
    // 
    this.btnShowOidTable = new Button(groupFilter, SWT.NONE);
    WidgetTestUtil.setTestId(this, "oidtable", btnShowOidTable);
    this.btnShowOidTable.setText(Messages.getString("show"));
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    this.btnShowOidTable.setLayoutData(gridData);
    this.btnShowOidTable.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            //?
            update();
        }
    });

    /*
     * 
     */
    this.infoList = new TrapDefineTableComposite(this, SWT.BORDER, this.define);
    WidgetTestUtil.setTestId(this, "pagelist", infoList);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalSpan = MAX_COLUMN;
    gridData.heightHint = 150;
    this.infoList.setLayoutData(gridData);
    this.infoList.getTableViewer().addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            checkButtonEnabled();
        }
    });

    /*
     * ?
     */
    Composite composite = new Composite(this, SWT.NONE);
    WidgetTestUtil.setTestId(this, null, composite);
    layout = new GridLayout(6, true);
    composite.setLayout(layout);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalSpan = MAX_COLUMN;
    composite.setLayoutData(gridData);

    /*
     * 
     */
    labelRecordNumber = new Label(composite, SWT.NONE);
    WidgetTestUtil.setTestId(this, "recordNumber", label);

    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.horizontalSpan = 2;
    labelRecordNumber.setLayoutData(gridData);
    updateRecordNumber(0, 0);

    // ???????
    int validButtonCount = 0;

    validButtonCount += (this.define.getButtonOptions() & ITableItemCompositeDefine.ADD) != 0 ? 1 : 0;
    validButtonCount += (this.define.getButtonOptions() & ITableItemCompositeDefine.MODIFY) != 0 ? 1 : 0;
    validButtonCount += (this.define.getButtonOptions() & ITableItemCompositeDefine.DELETE) != 0 ? 1 : 0;
    validButtonCount += (this.define.getButtonOptions() & ITableItemCompositeDefine.COPY) != 0 ? 1 : 0;

    if (4 - validButtonCount > 0) {
        label = new Label(composite, SWT.NONE);
        WidgetTestUtil.setTestId(this, "dummy", label);
        gridData = new GridData();
        gridData.horizontalSpan = 4 - validButtonCount;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        label.setLayoutData(gridData);
    }

    // 
    if ((this.define.getButtonOptions() & ITableItemCompositeDefine.ADD) != 0) {
        this.btnAdd = this.createButton(composite, Messages.getString("add"));
        WidgetTestUtil.setTestId(this, "add", btnAdd);
        this.btnAdd.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {

                // ?
                Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();

                CommonDialog dialog = define.createDialog(shell);
                if (dialog.open() == IDialogConstants.OK_ID) {
                    define.getTableItemInfoManager().add(define.getCurrentCreatedItem());

                    addItem(define.getCurrentCreatedItem());
                    updateMibList();
                    update();
                }
            }
        });
    }
    // 
    if ((this.define.getButtonOptions() & ITableItemCompositeDefine.MODIFY) != 0) {
        this.btnModify = this.createButton(composite, Messages.getString("modify"));
        WidgetTestUtil.setTestId(this, "modify", btnModify);
        this.btnModify.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                TrapValueInfo item = getSelectedItem();
                if (item != null) {

                    // ?
                    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();

                    CommonDialog dialog = define.createDialog(shell, item);
                    if (dialog.open() == IDialogConstants.OK_ID) {
                        Table table = infoList.getTableViewer().getTable();
                        WidgetTestUtil.setTestId(this, "modify", table);
                        int selectIndex = table.getSelectionIndex();
                        define.getTableItemInfoManager().modify(item, define.getCurrentCreatedItem());
                        table.setSelection(selectIndex);
                        removeItem(item);
                        addItem(define.getCurrentCreatedItem());
                        updateMibList();
                        update();
                    }
                } else {
                    MessageDialog.openWarning(null, Messages.getString("warning"),
                            Messages.getString("message.monitor.30"));
                }
            }
        });
    }

    // 
    if ((this.define.getButtonOptions() & ITableItemCompositeDefine.DELETE) != 0) {
        this.btnDelete = this.createButton(composite, Messages.getString("delete"));
        WidgetTestUtil.setTestId(this, "delete", btnDelete);
        this.btnDelete.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                List<TrapValueInfo> infos = getSelectedItems();

                if (infos.size() > 0) {
                    if (MessageDialog.openConfirm(null, Messages.getString("confirmed"),
                            Messages.getString("message.monitor.snmptrap.confirm.to.delete.selected.items"))) {

                        define.getTableItemInfoManager().delete(infos);
                        removeItem(infos.toArray(new TrapValueInfo[0]));
                        updateMibList();
                        update();
                    }
                } else {
                    MessageDialog.openWarning(null, Messages.getString("warning"),
                            Messages.getString("message.monitor.30"));
                }
            }
        });
    }

    // 
    if ((this.define.getButtonOptions() & ITableItemCompositeDefine.COPY) != 0) {
        this.btnCopy = this.createButton(composite, Messages.getString("copy"));
        WidgetTestUtil.setTestId(this, "copy", btnCopy);
        this.btnCopy.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                TrapValueInfo item = getSelectedItem();
                if (item != null) {

                    // ?
                    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();

                    CommonDialog dialog = define.createDialog(shell, item);
                    if (dialog.open() == IDialogConstants.OK_ID) {
                        Table table = infoList.getTableViewer().getTable();
                        WidgetTestUtil.setTestId(this, "modify", table);
                        int selectIndex = table.getSelectionIndex();
                        define.getTableItemInfoManager().add(define.getCurrentCreatedItem());
                        table.setSelection(selectIndex);
                        addItem(define.getCurrentCreatedItem());
                        updateMibList();
                        update();
                    }
                } else {
                    MessageDialog.openWarning(null, Messages.getString("warning"),
                            Messages.getString("message.monitor.30"));
                }
            }
        });
    }

    this.update();
}

From source file:com.contrastsecurity.ide.eclipse.ui.ContrastUIActivator.java

License:Open Source License

public static void statusDialog(String title, IStatus status) {
    Shell shell = getActiveWorkbenchShell();
    if (shell != null) {
        switch (status.getSeverity()) {
        case IStatus.ERROR:
            ErrorDialog.openError(shell, title, null, status);
            break;
        case IStatus.WARNING:
            MessageDialog.openWarning(shell, title, status.getMessage());
            break;
        case IStatus.INFO:
            MessageDialog.openInformation(shell, title, status.getMessage());
            break;
        }/*from   w  w  w. j a va2 s.  co m*/
    }
}

From source file:com.dubture.twig.ui.preferences.TwigEditorPreferencePage.java

License:Open Source License

@Override
protected void createFieldEditors() {

    String[][] options;//from   w  ww.j  a v a2  s .  c om

    MessageDialog.openWarning(getShell(), Messages.TwigEditorPreferencePage_2,
            Messages.TwigEditorPreferencePage_3);
    options = new String[][] { { TwigCoreConstants.SYNTAX_IGNORE, TwigCoreConstants.SYNTAX_IGNORE }, };

    addField(new ComboFieldEditor(TwigCoreConstants.SYNTAX_PROBLEM_SEVERITY,
            Messages.TwigEditorPreferencePage_4, options, getFieldEditorParent()));

}