Search in sources :

Example 61 with RowLayout

use of org.eclipse.swt.layout.RowLayout in project cubrid-manager by CUBRID.

the class SelectBrokerPage method createControl.

/**
	 * Create the control for this page
	 * 
	 * @param parent Composite
	 */
public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = 10;
    layout.marginWidth = 10;
    composite.setLayout(layout);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    composite.setLayoutData(gridData);
    Group brokerInfoGroup = new Group(composite, SWT.NONE);
    brokerInfoGroup.setText(Messages.grpSelectBroker);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    brokerInfoGroup.setLayoutData(gridData);
    layout = new GridLayout();
    layout.numColumns = 2;
    brokerInfoGroup.setLayout(layout);
    Label brokerNameLabel = new Label(brokerInfoGroup, SWT.LEFT);
    brokerNameLabel.setText(Messages.lblBrokerName);
    brokerNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    brokerNameCombo = new Combo(brokerInfoGroup, SWT.LEFT | SWT.BORDER | SWT.READ_ONLY);
    brokerNameCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, 100, -1));
    brokerNameCombo.addModifyListener(this);
    Label nickNameLable = new Label(brokerInfoGroup, SWT.LEFT);
    nickNameLable.setText(Messages.lblNickName);
    nickNameLable.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    nickNameText = new Text(brokerInfoGroup, SWT.LEFT | SWT.BORDER);
    nickNameText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    Label brokerPortLabel = new Label(brokerInfoGroup, SWT.LEFT);
    brokerPortLabel.setText(Messages.lblBrokerPort);
    brokerPortLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    brokerPortText = new Text(brokerInfoGroup, SWT.LEFT | SWT.BORDER | SWT.READ_ONLY);
    brokerPortText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, 100, -1));
    Label brokerStatusLabel = new Label(brokerInfoGroup, SWT.LEFT);
    brokerStatusLabel.setText(Messages.lblBrokerStatus);
    brokerStatusLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    brokerStatusText = new Text(brokerInfoGroup, SWT.LEFT | SWT.BORDER | SWT.READ_ONLY);
    brokerStatusText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, 100, -1));
    Label accessModeLabel = new Label(brokerInfoGroup, SWT.LEFT);
    accessModeLabel.setText(Messages.lblAccessMode);
    accessModeLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    accessModeText = new Text(brokerInfoGroup, SWT.LEFT | SWT.BORDER | SWT.READ_ONLY);
    accessModeText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, 100, -1));
    Composite btnComposite = new Composite(composite, SWT.NONE);
    RowLayout rowLayout = new RowLayout();
    rowLayout.spacing = 5;
    btnComposite.setLayout(rowLayout);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalAlignment = GridData.END;
    btnComposite.setLayoutData(gridData);
    addButton = new Button(btnComposite, SWT.NONE);
    addButton.setText(Messages.btnAddBroker);
    addButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            if (isBrokerNodeExist(brokerNameCombo.getText())) {
                CommonUITool.openErrorBox(getShell(), Messages.errBrokerExist);
                return;
            }
            addBrokerNodeToTable();
        }
    });
    createTable(composite);
    brokerNameCombo.setFocus();
    setTitle(Messages.titleSelectBrokerPage);
    setMessage(Messages.msgSelectBrokerPage);
    setControl(composite);
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Combo(org.eclipse.swt.widgets.Combo) Text(org.eclipse.swt.widgets.Text)

Example 62 with RowLayout

use of org.eclipse.swt.layout.RowLayout in project cubrid-manager by CUBRID.

the class SelectDbPage method createTable.

/**
	 * 
	 * Create table area
	 * 
	 * @param parent the parent composite
	 */
private void createTable(Composite parent) {
    Label tipLabel = new Label(parent, SWT.LEFT | SWT.WRAP);
    tipLabel.setText(Messages.lblDbListInfo);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    tipLabel.setLayoutData(gridData);
    final String[] columnNameArr = new String[] { Messages.colNickName, Messages.colDbName, Messages.colDbStatus, Messages.colIP, Messages.colPort, Messages.colServerStatus };
    dbTableViewer = CommonUITool.createCommonTableViewer(parent, null, columnNameArr, CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, 500));
    dbTable = dbTableViewer.getTable();
    for (int i = 0; i < dbTable.getColumnCount(); i++) {
        dbTable.getColumn(i).pack();
    }
    dbTable.addSelectionListener(new SelectionAdapter() {

        @SuppressWarnings("unchecked")
        public void widgetSelected(SelectionEvent event) {
            deleteDbButton.setEnabled(dbTable.getSelectionCount() > 0);
            addHANodeButton.setEnabled(false);
            StructuredSelection selection = (StructuredSelection) dbTableViewer.getSelection();
            if (selection == null || selection.isEmpty() || selection.size() > 1) {
                return;
            }
            Map<String, Object> map = (Map<String, Object>) selection.getFirstElement();
            DatabaseNode dbNode = (DatabaseNode) map.get("7");
            DBStatusType type = dbNode.getHaDatabaseStatus().getStatusType();
            if (type == DBStatusType.ACTIVE || type == DBStatusType.TO_BE_ACTIVE || type == DBStatusType.MAINTENANCE || type == DBStatusType.STANDBY || type == DBStatusType.TO_BE_STANDBY) {
                addHANodeButton.setEnabled(true);
            }
        }
    });
    dbTableViewer.setInput(dbNodeList);
    Composite composite = new Composite(parent, SWT.NONE);
    RowLayout rowLayout = new RowLayout();
    rowLayout.spacing = 5;
    composite.setLayout(rowLayout);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalAlignment = GridData.END;
    composite.setLayoutData(gridData);
    addHANodeButton = new Button(composite, SWT.NONE);
    addHANodeButton.setText(Messages.btnAddHADb);
    addHANodeButton.setToolTipText(Messages.tipBtnAddHaDb);
    addHANodeButton.addSelectionListener(new SelectionAdapter() {

        @SuppressWarnings("unchecked")
        public void widgetSelected(SelectionEvent event) {
            StructuredSelection selection = (StructuredSelection) dbTableViewer.getSelection();
            if (selection == null || selection.isEmpty() || selection.size() > 1) {
                return;
            }
            Map<String, Object> map = (Map<String, Object>) selection.getFirstElement();
            DatabaseNode dbNode = (DatabaseNode) map.get("7");
            List<HAHostStatusInfo> haHostStatusInfoList = (List<HAHostStatusInfo>) map.get("8");
            List<DatabaseNode> haDbNodeList = getHADatabaseList(dbNode.getHaDatabaseStatus(), haHostStatusInfoList, false);
            if (haDbNodeList == null) {
                haDbNodeList = new ArrayList<DatabaseNode>();
            }
            if (dbNode.getDbStatusType() == DBStatusType.ACTIVE || dbNode.getDbStatusType() == DBStatusType.TO_BE_ACTIVE) {
                haDbNodeList.add(0, dbNode);
            } else {
                haDbNodeList.add(dbNode);
            }
            addDbNodeToTable(haDbNodeList, haHostStatusInfoList);
            addHANodeButton.setEnabled(dbTable.getSelectionCount() > 0);
        }
    });
    addHANodeButton.setEnabled(false);
    deleteDbButton = new Button(composite, SWT.NONE);
    deleteDbButton.setText(Messages.btnDelete);
    deleteDbButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            StructuredSelection selection = (StructuredSelection) dbTableViewer.getSelection();
            if (selection != null && !selection.isEmpty()) {
                dbNodeList.removeAll(selection.toList());
            }
            dbTableViewer.refresh();
            deleteDbButton.setEnabled(dbTable.getSelectionCount() > 0);
        }
    });
    deleteDbButton.setEnabled(false);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ArrayList(java.util.ArrayList) DBStatusType(com.cubrid.cubridmanager.core.mondashboard.model.DBStatusType) HAHostStatusInfo(com.cubrid.cubridmanager.core.mondashboard.model.HAHostStatusInfo) DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Example 63 with RowLayout

use of org.eclipse.swt.layout.RowLayout in project cubrid-manager by CUBRID.

the class UserManagementTableViewerSorter method createDialogArea.

/**
	 * Create dialog area content
	 * 
	 * @param parent the parent composite
	 * @return the control
	 */
protected Control createDialogArea(Composite parent) {
    Composite parentComp = (Composite) super.createDialogArea(parent);
    Composite composite = new Composite(parentComp, SWT.NONE);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridLayout layout = new GridLayout();
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    composite.setLayout(layout);
    Label tipLabel = new Label(composite, SWT.LEFT | SWT.WRAP);
    tipLabel.setText(Messages.msgUserManagementList);
    tipLabel.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    // create CUBRID Manager user information table
    String[] columnNameArr = new String[] { Messages.tblColumnUserId, Messages.tblColumnDbAuth, Messages.tblColumnBrokerAuth, Messages.tblColumnMonitorAuth };
    final ServerType serverType = server.getServerInfo().getServerType();
    if (serverType == ServerType.DATABASE) {
        columnNameArr = new String[] { Messages.tblColumnUserId, Messages.tblColumnDbAuth, Messages.tblColumnMonitorAuth };
    } else if (serverType == ServerType.BROKER) {
        columnNameArr = new String[] { Messages.tblColumnUserId, Messages.tblColumnBrokerAuth, Messages.tblColumnMonitorAuth };
    }
    tableViewer = CommonUITool.createCommonTableViewer(composite, new UserManagementTableViewerSorter(), columnNameArr, CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, 200));
    userManageTable = tableViewer.getTable();
    initialTableModel();
    tableViewer.setInput(serverUserInfoTableList);
    for (int i = 0; i < userManageTable.getColumnCount(); i++) {
        userManageTable.getColumn(i).pack();
    }
    userManageTable.addSelectionListener(new SelectionAdapter() {

        @SuppressWarnings("rawtypes")
        public void widgetSelected(SelectionEvent event) {
            if (userManageTable.getSelectionCount() > 0) {
                StructuredSelection selection = (StructuredSelection) tableViewer.getSelection();
                boolean isHasAdmin = false;
                if (selection != null && !selection.isEmpty()) {
                    Iterator it = selection.iterator();
                    while (it.hasNext()) {
                        Map map = (Map) it.next();
                        if (map.get("0").equals("admin")) {
                            isHasAdmin = true;
                            break;
                        }
                    }
                }
                deleteButton.setEnabled(!isHasAdmin);
            } else {
                deleteButton.setEnabled(false);
            }
            if (userManageTable.getSelectionCount() == 1) {
                editButton.setEnabled(true);
            } else {
                editButton.setEnabled(false);
            }
        }
    });
    // create button
    Composite buttonComp = new Composite(composite, SWT.NONE);
    RowLayout rowLayout = new RowLayout();
    rowLayout.spacing = 5;
    buttonComp.setLayout(rowLayout);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalAlignment = GridData.END;
    buttonComp.setLayoutData(gridData);
    Button addButton = new Button(buttonComp, SWT.PUSH);
    addButton.setText(Messages.btnAdd);
    addButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            UserManagementWizard userManagementWizard = new UserManagementWizard(server, null, serverUserInfoList);
            CMWizardDialog dialog = new CMWizardDialog(getShell(), userManagementWizard);
            int returnCode = dialog.open();
            if (returnCode == IDialogConstants.OK_ID) {
                ServerUserInfo userInfo = userManagementWizard.getServerUserInfo();
                Map<String, Object> map = new HashMap<String, Object>();
                map.put("0", userInfo.getUserName());
                if (serverType == ServerType.BOTH) {
                    map.put("1", userInfo.getDbCreateAuthType().getText());
                    map.put("2", userInfo.getCasAuth().getText());
                    map.put("3", userInfo.getStatusMonitorAuth().getText());
                    map.put("4", userInfo);
                }
                if (serverType == ServerType.DATABASE) {
                    map.put("1", userInfo.getDbCreateAuthType().getText());
                    map.put("2", userInfo.getStatusMonitorAuth().getText());
                    map.put("3", userInfo);
                } else if (serverType == ServerType.BROKER) {
                    map.put("1", userInfo.getCasAuth().getText());
                    map.put("2", userInfo.getStatusMonitorAuth().getText());
                    map.put("3", userInfo);
                }
                serverUserInfoTableList.add(map);
                serverUserInfoList.add(userInfo);
                tableViewer.refresh();
                for (int i = 0; i < userManageTable.getColumnCount(); i++) {
                    userManageTable.getColumn(i).pack();
                }
            }
        }
    });
    editButton = new Button(buttonComp, SWT.PUSH);
    editButton.setText(Messages.btnEdit);
    editButton.addSelectionListener(new SelectionAdapter() {

        @SuppressWarnings({ "rawtypes", "unchecked" })
        public void widgetSelected(SelectionEvent event) {
            StructuredSelection selection = (StructuredSelection) tableViewer.getSelection();
            ServerUserInfo serverUserInfo = null;
            if (selection != null && !selection.isEmpty()) {
                Map map = (Map) selection.getFirstElement();
                if (serverType == ServerType.BOTH) {
                    serverUserInfo = (ServerUserInfo) map.get("4");
                } else {
                    serverUserInfo = (ServerUserInfo) map.get("3");
                }
                UserManagementWizard userManagementWizard = new UserManagementWizard(server, serverUserInfo, serverUserInfoList);
                CMWizardDialog dialog = new CMWizardDialog(getShell(), userManagementWizard);
                int returnCode = dialog.open();
                if (returnCode == IDialogConstants.OK_ID) {
                    ServerUserInfo userInfo = userManagementWizard.getServerUserInfo();
                    map.put("0", userInfo.getUserName());
                    if (serverType == ServerType.BOTH) {
                        map.put("1", userInfo.getDbCreateAuthType().getText());
                        map.put("2", userInfo.getCasAuth().getText());
                        map.put("3", userInfo.getStatusMonitorAuth().getText());
                        map.put("4", userInfo);
                    }
                    if (serverType == ServerType.DATABASE) {
                        map.put("1", userInfo.getDbCreateAuthType().getText());
                        map.put("2", userInfo.getStatusMonitorAuth().getText());
                        map.put("3", userInfo);
                    } else if (serverType == ServerType.BROKER) {
                        map.put("1", userInfo.getCasAuth().getText());
                        map.put("2", userInfo.getStatusMonitorAuth().getText());
                        map.put("3", userInfo);
                    }
                    tableViewer.refresh();
                    for (int i = 0; i < userManageTable.getColumnCount(); i++) {
                        userManageTable.getColumn(i).pack();
                    }
                }
            }
        }
    });
    editButton.setEnabled(userManageTable.getSelectionCount() == 1);
    deleteButton = new Button(buttonComp, SWT.PUSH);
    deleteButton.setText(Messages.btnDelete);
    deleteButton.addSelectionListener(new SelectionAdapter() {

        @SuppressWarnings("rawtypes")
        public void widgetSelected(SelectionEvent event) {
            boolean isDelete = CommonUITool.openConfirmBox(getShell(), Messages.msgDeleteUserConfirm);
            if (!isDelete) {
                return;
            }
            StructuredSelection selection = (StructuredSelection) tableViewer.getSelection();
            if (selection != null && !selection.isEmpty()) {
                Map[] userInfoMapArr = new Map[selection.size()];
                Iterator it = selection.iterator();
                int i = 0;
                while (it.hasNext()) {
                    Map map = (Map) it.next();
                    userInfoMapArr[i] = map;
                    i++;
                }
                deleteUser(userInfoMapArr);
            }
            tableViewer.refresh();
        }
    });
    deleteButton.setEnabled(userManageTable.getSelectionCount() == 1);
    setTitle(Messages.titleUserManagementDialog);
    setMessage(Messages.msgUserManagementDialog);
    return parentComp;
}
Also used : ServerType(com.cubrid.cubridmanager.core.common.model.ServerType) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) UserManagementWizard(com.cubrid.cubridmanager.ui.common.control.UserManagementWizard) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Iterator(java.util.Iterator) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo) HashMap(java.util.HashMap) Map(java.util.Map) CMWizardDialog(com.cubrid.common.ui.spi.dialog.CMWizardDialog)

Example 64 with RowLayout

use of org.eclipse.swt.layout.RowLayout in project cubrid-manager by CUBRID.

the class PartitionEditListPage method createPartitionListValueGroup.

/**
	 * 
	 * Create the partition value list group
	 * 
	 * @param parent the parent composite
	 */
private void createPartitionListValueGroup(Composite parent) {
    Group partitionListValueGroup = new Group(parent, SWT.NONE);
    partitionListValueGroup.setText(Messages.grpExpressionValue);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    partitionListValueGroup.setLayoutData(gridData);
    GridLayout layout = new GridLayout();
    partitionListValueGroup.setLayout(layout);
    Composite composite = new Composite(partitionListValueGroup, SWT.NONE);
    composite.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    layout = new GridLayout();
    layout.numColumns = 3;
    composite.setLayout(layout);
    Label partitionValueLabel = new Label(composite, SWT.NONE);
    partitionValueLabel.setText(Messages.lblPartitionValue);
    partitionValueLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    partitionValueCombo = new Combo(composite, SWT.BORDER | SWT.MULTI);
    partitionValueCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    Button addButton = new Button(composite, SWT.NONE);
    addButton.setText(Messages.btnAdd);
    addButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    addButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            String value = partitionValueCombo.getText();
            if (!isValidData(value)) {
                partitionValueCombo.setFocus();
                return;
            }
            if (isValueExist(value)) {
                CommonUITool.openErrorBox(Messages.bind(Messages.errValueExist, value));
                partitionValueCombo.setText("");
                partitionValueCombo.setFocus();
                return;
            }
            new TableItem(listValueTable, SWT.NONE).setText(value);
            partitionValueCombo.setText("");
            setPageComplete(validate());
            partitionValueCombo.setFocus();
        }

        /**
			 * Check this value whether already exist
			 * 
			 * @param value the value
			 * @return <code>true</code> if exist;otherwise <code>false</code>
			 */
        private boolean isValueExist(String value) {
            for (int i = 0; i < listValueTable.getItemCount(); i++) {
                String val = listValueTable.getItem(i).getText();
                if (value.equals(val)) {
                    return true;
                }
            }
            for (int i = 0; i < partitionInfoList.size(); i++) {
                List<String> valuesList = partitionInfoList.get(i).getPartitionValues();
                for (int j = 0; j < valuesList.size(); j++) {
                    if (value.equals(valuesList.get(j))) {
                        return true;
                    }
                }
            }
            return false;
        }

        /**
			 * 
			 * Check this value whether valid
			 * 
			 * @param newValue The string
			 * @return boolean
			 */
        private boolean isValidData(String newValue) {
            String exprDataType = partitionExprTypeCombo.getText();
            String resultMsg = FieldHandlerUtils.isValidData(exprDataType, newValue);
            if (null == resultMsg) {
                return true;
            } else if (resultMsg.length() > 0) {
                CommonUITool.openErrorBox(resultMsg);
            }
            return false;
        }
    });
    Label listValueLabel = new Label(composite, SWT.NONE);
    listValueLabel.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 3, 1, -1, -1));
    listValueLabel.setText(Messages.lblExprValueInfo);
    listValueTable = new Table(composite, SWT.FULL_SELECTION | SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    listValueTable.setLayout(TableViewUtil.createTableViewLayout(new int[] { 100 }));
    listValueTable.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, 200));
    listValueTable.setHeaderVisible(true);
    listValueTable.setLinesVisible(false);
    TableViewUtil.createTableColumn(listValueTable, SWT.LEFT, Messages.tblColExprValue);
    Composite bottomComp = new Composite(composite, SWT.NONE);
    RowLayout rowLayout = new RowLayout();
    rowLayout.spacing = 5;
    bottomComp.setLayout(rowLayout);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 3;
    gridData.horizontalAlignment = GridData.END;
    bottomComp.setLayoutData(gridData);
    final Button deleteValueButton = new Button(bottomComp, SWT.NONE);
    deleteValueButton.setText(Messages.btnDel);
    deleteValueButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            int[] indices = listValueTable.getSelectionIndices();
            if (indices == null || indices.length == 0) {
                return;
            }
            listValueTable.remove(indices);
            setPageComplete(validate());
        }
    });
    deleteValueButton.setEnabled(false);
    listValueTable.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            int[] indices = listValueTable.getSelectionIndices();
            if (indices == null || indices.length == 0) {
                deleteValueButton.setEnabled(false);
                return;
            }
            deleteValueButton.setEnabled(true);
        }
    });
}
Also used : Group(org.eclipse.swt.widgets.Group) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TableItem(org.eclipse.swt.widgets.TableItem) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ArrayList(java.util.ArrayList) List(java.util.List)

Example 65 with RowLayout

use of org.eclipse.swt.layout.RowLayout in project azure-tools-for-java by Microsoft.

the class QueueFileEditor method createToolbar.

private void createToolbar(Composite parent) {
    GridLayout gridLayout = new GridLayout(1, false);
    GridData gridData = new GridData();
    gridData.horizontalAlignment = SWT.FILL;
    gridData.grabExcessHorizontalSpace = true;
    Composite container = new Composite(parent, 0);
    container.setLayout(gridLayout);
    container.setLayoutData(gridData);
    RowLayout rowLayout = new RowLayout();
    rowLayout.type = SWT.HORIZONTAL;
    rowLayout.wrap = false;
    Composite buttonsContainer = new Composite(container, SWT.NONE);
    gridData = new GridData();
    gridData.horizontalAlignment = SWT.RIGHT;
    buttonsContainer.setLayout(rowLayout);
    refreshButton = new Button(buttonsContainer, SWT.PUSH);
    refreshButton.setImage(Activator.getImageDescriptor("icons/storagerefresh.png").createImage());
    refreshButton.setToolTipText("Refresh");
    addMessageButton = new Button(buttonsContainer, SWT.PUSH);
    addMessageButton.setImage(Activator.getImageDescriptor("icons/newmessage_queue.png").createImage());
    addMessageButton.setToolTipText("Add");
    dequeueMessageButton = new Button(buttonsContainer, SWT.PUSH);
    dequeueMessageButton.setImage(Activator.getImageDescriptor("icons/dequeue.png").createImage());
    dequeueMessageButton.setToolTipText("Dequeue");
    clearQueueButton = new Button(buttonsContainer, SWT.PUSH);
    clearQueueButton.setImage(Activator.getImageDescriptor("icons/clearqueue.png").createImage());
    clearQueueButton.setToolTipText("Clear queue");
    refreshButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            fileEditorVirtualNode.doAction(REFRESH);
        }
    });
    dequeueMessageButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            fileEditorVirtualNode.doAction(DEQUEUE);
        }
    });
    addMessageButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            fileEditorVirtualNode.doAction(ADD);
        }
    });
    clearQueueButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            fileEditorVirtualNode.doAction(CLEAR_QUEUE);
        }
    });
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Aggregations

RowLayout (org.eclipse.swt.layout.RowLayout)86 Composite (org.eclipse.swt.widgets.Composite)73 GridData (org.eclipse.swt.layout.GridData)55 Button (org.eclipse.swt.widgets.Button)54 GridLayout (org.eclipse.swt.layout.GridLayout)52 Label (org.eclipse.swt.widgets.Label)44 SelectionEvent (org.eclipse.swt.events.SelectionEvent)41 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)34 Group (org.eclipse.swt.widgets.Group)27 Text (org.eclipse.swt.widgets.Text)23 Combo (org.eclipse.swt.widgets.Combo)19 Shell (org.eclipse.swt.widgets.Shell)17 Display (org.eclipse.swt.widgets.Display)16 Point (org.eclipse.swt.graphics.Point)12 ArrayList (java.util.ArrayList)10 StyledText (org.eclipse.swt.custom.StyledText)10 Table (org.eclipse.swt.widgets.Table)10 List (java.util.List)9 SelectionListener (org.eclipse.swt.events.SelectionListener)9 FillLayout (org.eclipse.swt.layout.FillLayout)9