Search in sources :

Example 1 with LogContentDetailDialog

use of com.cubrid.cubridmanager.ui.logs.dialog.LogContentDetailDialog in project cubrid-manager by CUBRID.

the class LogEditorPart method createPartControl.

/**
	 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
	 * @param parent the parent control
	 * @see IWorkbenchPart
	 */
public void createPartControl(Composite parent) {
    final Composite compositeLog = new Composite(parent, SWT.NONE);
    {
        GridLayout gridLayoutLog = new GridLayout();
        gridLayoutLog.verticalSpacing = 0;
        gridLayoutLog.marginWidth = 0;
        gridLayoutLog.marginHeight = 0;
        gridLayoutLog.horizontalSpacing = 5;
        gridLayoutLog.numColumns = 8;
        compositeLog.setLayout(gridLayoutLog);
    }
    final String type = this.cubridNode.getType();
    table = new Table(compositeLog, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
    {
        table.setHeaderVisible(true);
        GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
        gridData.horizontalSpan = 8;
        gridData.verticalSpan = 10;
        gridData.heightHint = 600;
        table.setLayoutData(gridData);
        table.setLinesVisible(true);
    }
    // fill in context menu
    if (CubridNodeType.BROKER_SQL_LOG.equals(type) || CubridNodeType.LOGS_BROKER_ERROR_LOG.equals(type) || CubridNodeType.LOGS_MANAGER_ERROR_LOG.equals(type) || CubridNodeType.LOGS_SERVER_DATABASE_LOG.equals(type) || CubridNodeType.LOGS_APPLY_DATABASE_LOG.equals(type) || CubridNodeType.LOGS_COPY_DATABASE_LOG.equals(type)) {
        //Create the context menu
        MenuManager contextMenuManager = new MenuManager();
        contextMenuManager.setRemoveAllWhenShown(true);
        contextMenuManager.addMenuListener(new IMenuListener() {

            public void menuAboutToShow(IMenuManager manager) {
                buildPopupMenu(manager, type);
            }
        });
        Menu contextMenu = contextMenuManager.createContextMenu(table);
        table.setMenu(contextMenu);
        //Add listener
        table.addKeyListener(new KeyAdapter() {

            public void keyPressed(KeyEvent event) {
                if ((event.stateMask & SWT.CTRL) != 0 && (event.stateMask & SWT.SHIFT) == 0 && event.keyCode == 'c') {
                    copyDataToClipboard(type);
                }
            }
        });
    }
    table.addListener(SWT.MouseDoubleClick, new Listener() {

        public void handleEvent(Event event) {
            if (CubridNodeType.BROKER_SQL_LOG.equals(cubridNode.getType())) {
                TableItem[] items = table.getSelection();
                if (items != null && items.length == 1) {
                    final String content = items[0].getText(1);
                    new LogContentDetailDialog(getSite().getShell(), content).open();
                }
            } else if (CubridNodeType.LOGS_MANAGER_ERROR_LOG.equals(cubridNode.getType())) {
                TableItem[] items = table.getSelection();
                if (items != null && items.length == 1) {
                    final String content = items[0].getText(4);
                    new LogContentDetailDialog(getSite().getShell(), content).open();
                }
            } else if (CubridNodeType.LOGS_BROKER_ERROR_LOG.equals(cubridNode.getType())) {
                TableItem[] items = table.getSelection();
                if (items != null && items.length == 1) {
                    final String content = items[0].getText(6);
                    new LogContentDetailDialog(getSite().getShell(), content).open();
                }
            }
        }
    });
    // add bottom composite for page
    Label labelCharset = new Label(compositeLog, SWT.NONE);
    {
        labelCharset.setText(Messages.labelCharset);
        charsetCombo = new Combo(compositeLog, SWT.BORDER);
        final GridData gdCharsetText = CommonUITool.createGridData(1, 1, -1, -1);
        charsetCombo.setLayoutData(gdCharsetText);
        charsetCombo.setItems(QueryOptions.getAllCharset(null));
        charsetCombo.setText(charsetName);
    }
    Button viewLogBtn = new Button(compositeLog, SWT.NONE);
    {
        viewLogBtn.setText(Messages.viewLogJobName);
        viewLogBtn.setLayoutData(CommonUITool.createGridData(1, 1, 100, -1));
        viewLogBtn.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                String charsetName = charsetCombo.getText();
                try {
                    "".getBytes(charsetName);
                } catch (UnsupportedEncodingException e) {
                    CommonUITool.openErrorBox(Messages.errCharset);
                    charsetCombo.setFocus();
                    return;
                }
                setCharsetName(charsetName);
                if (!CubridNodeType.LOGS_MANAGER_ERROR_LOG.equals(type) && !CubridNodeType.LOGS_MANAGER_ACCESS_LOG.equals(type)) {
                    connect(false);
                }
                if (CubridNodeType.LOGS_MANAGER_ERROR_LOG.equals(type) || CubridNodeType.LOGS_MANAGER_ACCESS_LOG.equals(type)) {
                    managerConnect();
                    updateManagerLogTable();
                }
            }
        });
    }
    // page button
    if (!CubridNodeType.LOGS_MANAGER_ERROR_LOG.equals(type) && !CubridNodeType.LOGS_MANAGER_ACCESS_LOG.equals(type)) {
        pageText = new Text(compositeLog, SWT.BORDER);
        {
            pageText.setVisible(true);
            pageText.setEditable(false);
            GridData gridData = createPageBtnGridData(150);
            gridData.grabExcessHorizontalSpace = true;
            pageText.setLayoutData(gridData);
        }
        buttonFirst = new Button(compositeLog, SWT.NONE);
        {
            buttonFirst.setVisible(true);
            buttonFirst.setText("|<");
            buttonFirst.setLayoutData(createPageBtnGridData(60));
            buttonFirst.addSelectionListener(new SelectionAdapter() {

                public void widgetSelected(SelectionEvent event) {
                    lineStart = 1;
                    lineEnd = 100;
                    connect(false);
                }
            });
        }
        buttonPrev = new Button(compositeLog, SWT.NONE);
        {
            buttonPrev.setVisible(true);
            buttonPrev.setText("<");
            buttonPrev.setLayoutData(createPageBtnGridData(60));
            buttonPrev.addSelectionListener(new SelectionAdapter() {

                public void widgetSelected(SelectionEvent event) {
                    lineStart -= 100;
                    if (lineStart < 1) {
                        lineStart = 1;
                    }
                    lineEnd = lineStart + 99;
                    connect(false);
                }
            });
        }
        buttonNext = new Button(compositeLog, SWT.NONE);
        {
            buttonNext.setVisible(true);
            buttonNext.setText(">");
            buttonNext.setLayoutData(createPageBtnGridData(60));
            buttonNext.addSelectionListener(new SelectionAdapter() {

                public void widgetSelected(SelectionEvent event) {
                    lineStart += 100;
                    if (lineStart > lineTot) {
                        lineStart = lineTot;
                    }
                    lineEnd = lineStart + 99;
                    if (lineEnd > lineTot) {
                        lineEnd = lineTot;
                    }
                    connect(false);
                }
            });
        }
        buttonEnd = new Button(compositeLog, SWT.NONE);
        {
            buttonEnd.setVisible(true);
            buttonEnd.setText(">|");
            buttonEnd.setLayoutData(createPageBtnGridData(60));
            buttonEnd.addSelectionListener(new SelectionAdapter() {

                public void widgetSelected(SelectionEvent event) {
                    lineEnd = lineTot;
                    lineStart = lineEnd - lineTot % 100 + 1;
                    connect(false);
                }
            });
        }
    }
    // manager log page button
    if (CubridNodeType.LOGS_MANAGER_ERROR_LOG.equals(type) || CubridNodeType.LOGS_MANAGER_ACCESS_LOG.equals(type)) {
        pageText = new Text(compositeLog, SWT.BORDER);
        {
            pageText.setVisible(true);
            pageText.setEditable(false);
            GridData gridData = createPageBtnGridData(150);
            gridData.grabExcessHorizontalSpace = true;
            pageText.setLayoutData(gridData);
        }
        buttonFirst = new Button(compositeLog, SWT.NONE);
        buttonFirst.setVisible(true);
        buttonFirst.setText("|<");
        buttonFirst.setLayoutData(createPageBtnGridData(60));
        buttonFirst.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                pageInfo.setCurrentPage(1);
                updateManagerLogTable();
            }
        });
        buttonPrev = new Button(compositeLog, SWT.NONE);
        buttonPrev.setVisible(true);
        buttonPrev.setText("<");
        buttonPrev.setLayoutData(createPageBtnGridData(60));
        buttonPrev.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                pageInfo.setCurrentPage(pageInfo.getCurrentPage() - 1);
                updateManagerLogTable();
            }
        });
        buttonNext = new Button(compositeLog, SWT.NONE);
        buttonNext.setVisible(true);
        buttonNext.setText(">");
        buttonNext.setLayoutData(createPageBtnGridData(60));
        buttonNext.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                pageInfo.setCurrentPage(pageInfo.getCurrentPage() + 1);
                updateManagerLogTable();
            }
        });
        buttonEnd = new Button(compositeLog, SWT.NONE);
        buttonEnd.setVisible(true);
        buttonEnd.setText(">|");
        buttonEnd.setLayoutData(createPageBtnGridData(60));
        buttonEnd.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                pageInfo.setCurrentPage(pageInfo.getPages());
                updateManagerLogTable();
            }
        });
    }
    compositeLog.pack();
}
Also used : Table(org.eclipse.swt.widgets.Table) IMenuListener(org.eclipse.jface.action.IMenuListener) Listener(org.eclipse.swt.widgets.Listener) Composite(org.eclipse.swt.widgets.Composite) KeyAdapter(org.eclipse.swt.events.KeyAdapter) LogContentDetailDialog(com.cubrid.cubridmanager.ui.logs.dialog.LogContentDetailDialog) TableItem(org.eclipse.swt.widgets.TableItem) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Combo(org.eclipse.swt.widgets.Combo) Text(org.eclipse.swt.widgets.Text) IMenuListener(org.eclipse.jface.action.IMenuListener) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) SelectionEvent(org.eclipse.swt.events.SelectionEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu)

Aggregations

CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)1 LogContentDetailDialog (com.cubrid.cubridmanager.ui.logs.dialog.LogContentDetailDialog)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 IMenuListener (org.eclipse.jface.action.IMenuListener)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 MenuManager (org.eclipse.jface.action.MenuManager)1 KeyAdapter (org.eclipse.swt.events.KeyAdapter)1 KeyEvent (org.eclipse.swt.events.KeyEvent)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Button (org.eclipse.swt.widgets.Button)1 Combo (org.eclipse.swt.widgets.Combo)1 Composite (org.eclipse.swt.widgets.Composite)1 Event (org.eclipse.swt.widgets.Event)1 Label (org.eclipse.swt.widgets.Label)1 Listener (org.eclipse.swt.widgets.Listener)1 Menu (org.eclipse.swt.widgets.Menu)1 Table (org.eclipse.swt.widgets.Table)1