Search in sources :

Example 31 with FormLayout

use of org.eclipse.swt.layout.FormLayout in project tdi-studio-se by Talend.

the class RuntimeGraphcsComposite method createControls.

@Override
protected void createControls(Composite parent) {
    chartsPage = new Composite(parent, SWT.NULL);
    parent.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    chartsPage.setBackground(parent.getBackground());
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = 0;
    formLayout.marginHeight = 0;
    chartsPage.setLayout(formLayout);
    FormData pageData = new FormData();
    pageData.top = new FormAttachment(0, 0);
    pageData.bottom = new FormAttachment(100, 0);
    pageData.left = new FormAttachment(0, 0);
    pageData.right = new FormAttachment(100, 0);
    chartsPage.setLayoutData(pageData);
    mBeanServerChangeListener = new IMBeanServerChangeListener() {

        @Override
        public void serverChanged(MBeanServerEvent event) {
            new RefreshJob(Messages.reconstructChartJobLabel, toString()) {

                @Override
                protected void refreshUI() {
                    IActiveJvm jvm = getJvm();
                    if (jvm != null) {
                        reconstructCharts(jvm, false);
                    }
                }
            }.schedule();
        }
    };
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IHelpContextIds.TIMELINE_PAGE);
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) RefreshJob(org.talend.designer.runtime.visualization.internal.ui.RefreshJob) IActiveJvm(org.talend.designer.runtime.visualization.IActiveJvm) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) IMBeanServerChangeListener(org.talend.designer.runtime.visualization.MBean.IMBeanServerChangeListener) MBeanServerEvent(org.talend.designer.runtime.visualization.MBean.MBeanServerEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 32 with FormLayout

use of org.eclipse.swt.layout.FormLayout in project tdi-studio-se by Talend.

the class RuntimeGraphcsComposite method createReportField.

/*  private void createInfoField(Composite parent) {

        infoComposite = createFlatFormComposite(parent, new FormToolkit(Display.getDefault()));
        FormLayout reportLayout = new FormLayout();
        reportLayout.marginWidth = 0;
        reportLayout.marginHeight = 0;
        infoComposite.setLayout(reportLayout);
        FormData reportData = new FormData();
        reportData.left = new FormAttachment(65, 5);
        reportData.right = new FormAttachment(100, -5);
        reportData.top = new FormAttachment(50, 0);
        reportData.bottom = new FormAttachment(100, -5);
        infoComposite.setLayoutData(reportData);

        Group group = new Group(infoComposite, SWT.NULL);
        FormLayout groupLayout = new FormLayout();
        groupLayout.marginWidth = 0;
        groupLayout.marginHeight = 0;
        group.setLayout(groupLayout);
        FormData groupData = new FormData();
        groupData.left = new FormAttachment(0, 0);
        groupData.right = new FormAttachment(100, 0);
        groupData.top = new FormAttachment(0, 0);
        groupData.bottom = new FormAttachment(100, 0);
        group.setLayoutData(groupData);
        group.setText("Run job Informations");

        infoField = new Text(group, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.READ_ONLY);
        infoField.setEditable(false);
        infoField.setBackground(group.getBackground());

        FormData data;
        data = new FormData();
        data.left = new FormAttachment(0, 0);
        data.right = new FormAttachment(100, 0);
        data.top = new FormAttachment(0, 0);
        data.bottom = new FormAttachment(100, 0);
        infoField.setLayoutData(data);
    }*/
private void createReportField(Composite parent) {
    reportComposite = createFlatFormComposite(parent, new FormToolkit(Display.getDefault()));
    FormLayout reportLayout = new FormLayout();
    reportComposite.setLayout(reportLayout);
    FormData reportData = new FormData();
    reportData.left = new FormAttachment(65, 5);
    reportData.right = new FormAttachment(100, -5);
    reportData.top = new FormAttachment(0, 0);
    reportData.bottom = new FormAttachment(100, -5);
    reportComposite.setLayoutData(reportData);
    Group group = new Group(reportComposite, SWT.NULL);
    FormLayout groupLayout = new FormLayout();
    group.setLayout(groupLayout);
    FormData groupData = new FormData();
    groupData.left = new FormAttachment(0, 0);
    groupData.right = new FormAttachment(100, 0);
    groupData.top = new FormAttachment(0, 0);
    groupData.bottom = new FormAttachment(100, 0);
    group.setLayoutData(groupData);
    //$NON-NLS-1$
    group.setText("Job execution information");
    reportField = new StyledText(group, SWT.WRAP | SWT.V_SCROLL | SWT.READ_ONLY);
    //may be CoreUIPlugin.setCSSClass can do this globally ,check later
    reportField.setBackground(getDisplay().getSystemColor(SWT.COLOR_WHITE));
    FormData data;
    data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    data.top = new FormAttachment(0, 0);
    data.bottom = new FormAttachment(93, 0);
    reportField.setLayoutData(data);
    displayReportField();
    //export button
    Button exportButton = new Button(group, SWT.PUSH);
    //$NON-NLS-1$
    exportButton.setText("Export");
    FormData exportData = new FormData();
    exportData.left = new FormAttachment(100, -70);
    exportData.right = new FormAttachment(100, 0);
    exportData.bottom = new FormAttachment(100, -1);
    exportButton.setLayoutData(exportData);
    exportButton.setEnabled(true);
    exportButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (messageManager == null || messageManager.getMessages().size() < 1) {
                //$NON-NLS-1$ //$NON-NLS-2$
                MessageDialog.openWarning(getShell(), "Warning", "No log to export.");
                return;
            }
            UnboundedFifoBuffer messages = messageManager.getMessages();
            Iterator iterator = messages.iterator();
            StringBuilder content = new StringBuilder();
            while (iterator.hasNext()) {
                ReportMessage message = (ReportMessage) iterator.next();
                content.append(message.getContent());
            }
            if (isMonitoring) {
                //$NON-NLS-1$ //$NON-NLS-2$
                MessageDialog.openWarning(getShell(), "Warning", "Waiting for job done.");
                return;
            }
            FileDialog dialog = new FileDialog(getShell(), SWT.SAVE);
            //$NON-NLS-1$
            dialog.setFilterPath(".");
            String fileName = dialog.open();
            if (fileName != null) {
                FileWriter writer = null;
                try {
                    writer = new FileWriter(fileName);
                    writer.write(content.toString());
                } catch (IOException e1) {
                    e1.printStackTrace();
                } finally {
                    try {
                        if (writer != null) {
                            writer.close();
                        }
                    } catch (IOException e1) {
                        e1.printStackTrace();
                    }
                }
            }
        }
    });
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) IMonitoredMXBeanGroup(org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup) Group(org.eclipse.swt.widgets.Group) StyledText(org.eclipse.swt.custom.StyledText) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) FileWriter(java.io.FileWriter) ReportMessage(org.talend.designer.runtime.visualization.ReportMessage) IOException(java.io.IOException) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Iterator(java.util.Iterator) UnboundedFifoBuffer(org.apache.commons.collections.buffer.UnboundedFifoBuffer) FileDialog(org.eclipse.swt.widgets.FileDialog) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 33 with FormLayout

use of org.eclipse.swt.layout.FormLayout in project tdi-studio-se by Talend.

the class RuntimeGraphcsComposite method reconstructCharts.

void reconstructCharts(IActiveJvm activeJvm, boolean connected) {
    if (chartsPage.isDisposed()) {
        return;
    }
    if (connected) {
        try {
            loadOverviewChartSet(activeJvm);
        } catch (JvmCoreException e) {
            Activator.log(Messages.configureMonitoredAttributesFailedMsg, e);
        }
    }
    List<IMonitoredMXBeanGroup> groups = activeJvm.getMBeanServer().getMonitoredAttributeGroups();
    if (groups.size() == 0) {
        return;
    }
    for (TimelineChart chart : charts) {
        chart.dispose();
    }
    charts.clear();
    if (chartComposite != null && !chartComposite.isDisposed()) {
        chartComposite.dispose();
    }
    chartComposite = new Composite(chartsPage, SWT.NONE);
    FormLayout chartLayout = new FormLayout();
    chartLayout.marginHeight = 0;
    chartLayout.marginWidth = 0;
    chartComposite.setLayout(chartLayout);
    FormData chartComData = new FormData();
    chartComData.top = new FormAttachment(0, 0);
    chartComData.bottom = new FormAttachment(100, 0);
    chartComData.left = new FormAttachment(0, 0);
    chartComData.right = new FormAttachment(100, 0);
    chartComposite.setLayoutData(chartComData);
    for (IMonitoredMXBeanGroup group : groups) {
        createSection(chartComposite, group);
    }
    createReportField(chartComposite);
    //      createInfoField(chartComposite);
    chartsPage.layout();
    chartsPage.setVisible(true);
    refresh();
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) IMonitoredMXBeanGroup(org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) TimelineChart(org.talend.designer.runtime.visualization.internal.ui.properties.timeline.TimelineChart) FormAttachment(org.eclipse.swt.layout.FormAttachment) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Example 34 with FormLayout

use of org.eclipse.swt.layout.FormLayout in project tdi-studio-se by Talend.

the class RuntimeGraphcsComposite method createMessagePage.

private Composite createMessagePage(Composite parent) {
    messagePage = new Composite(parent, SWT.NONE);
    FormLayout messageLayout = new FormLayout();
    messageLayout.marginHeight = 0;
    messageLayout.marginWidth = 0;
    messagePage.setLayout(messageLayout);
    messagePage.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    FormToolkit toolkit = new FormToolkit(Display.getDefault());
    Hyperlink hyperlink = toolkit.createHyperlink(messagePage, Messages.loadDefaultChartSetLabel, SWT.NONE);
    hyperlink.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent event) {
            try {
                new LoadChartAction(RuntimeGraphcsComposite.this).loadDefaultChartSet();
            } catch (JvmCoreException e) {
                Activator.log(Messages.loadChartSetFailedMsg, e);
            }
        }
    });
    return messagePage;
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) LoadChartAction(org.talend.designer.runtime.visualization.internal.ui.properties.timeline.LoadChartAction) Hyperlink(org.eclipse.ui.forms.widgets.Hyperlink) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Example 35 with FormLayout

use of org.eclipse.swt.layout.FormLayout in project tdi-studio-se by Talend.

the class RuntimeGraphcsComposite method createSection.

private void createSection(Composite parent, IMonitoredMXBeanGroup group) {
    if (parent.isDisposed()) {
        return;
    }
    FormToolkit tookit = new FormToolkit(Display.getDefault());
    ExpandableComposite section = tookit.createSection(parent, ExpandableComposite.NO_TITLE);
    section.setText(group.getName());
    FormLayout sectionLayout = new FormLayout();
    sectionLayout.marginWidth = 0;
    sectionLayout.marginHeight = 0;
    section.setLayout(sectionLayout);
    FormData sectionData = new FormData();
    if (group.getName().equals(MonitorAttributeName.HEAP_MEMORY)) {
        sectionData.left = new FormAttachment(0, 0);
        sectionData.right = new FormAttachment(65, 0);
        sectionData.top = new FormAttachment(0, 6);
        sectionData.bottom = new FormAttachment(53, -5);
    } else if (group.getName().equals(MonitorAttributeName.THREAD_COUNT)) {
        sectionData.left = new FormAttachment(50, 5);
        sectionData.right = new FormAttachment(100, -5);
        sectionData.top = new FormAttachment(50, 2);
        sectionData.bottom = new FormAttachment(100, 0);
    } else if (group.getName().equals(MonitorAttributeName.CPU_USE)) {
        sectionData.left = new FormAttachment(0, 0);
        sectionData.right = new FormAttachment(65, 0);
        sectionData.top = new FormAttachment(53, 0);
        sectionData.bottom = new FormAttachment(100, -6);
    }
    section.setLayoutData(sectionData);
    Composite flatFormComposite = createFlatFormComposite(section, tookit);
    FormLayout formLayout = new FormLayout();
    formLayout.marginHeight = 0;
    formLayout.marginWidth = 0;
    flatFormComposite.setLayout(formLayout);
    TimelineChart chart = new TimelineChart(flatFormComposite, section, group, SWT.NONE, toString() + getJvm().getPid());
    charts.add(chart);
    FormData data;
    data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    data.top = new FormAttachment(0, 0);
    data.bottom = new FormAttachment(100, 0);
    chart.setLayoutData(data);
    section.setClient(flatFormComposite);
    ArrayList<Action> list = new ArrayList<Action>();
    list.add(garbageCollectorAction);
    if (group.getName().equals(MonitorAttributeName.HEAP_MEMORY)) {
        addSectionActions(section, list);
    }
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) LoadChartAction(org.talend.designer.runtime.visualization.internal.ui.properties.timeline.LoadChartAction) GarbageAction(org.talend.designer.runtime.visualization.internal.ui.properties.memory.GarbageAction) Action(org.eclipse.jface.action.Action) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ArrayList(java.util.ArrayList) TimelineChart(org.talend.designer.runtime.visualization.internal.ui.properties.timeline.TimelineChart) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Aggregations

FormLayout (org.eclipse.swt.layout.FormLayout)726 FormData (org.eclipse.swt.layout.FormData)651 FormAttachment (org.eclipse.swt.layout.FormAttachment)649 Label (org.eclipse.swt.widgets.Label)503 Button (org.eclipse.swt.widgets.Button)484 SelectionEvent (org.eclipse.swt.events.SelectionEvent)444 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)407 Text (org.eclipse.swt.widgets.Text)390 Composite (org.eclipse.swt.widgets.Composite)384 Shell (org.eclipse.swt.widgets.Shell)365 ModifyListener (org.eclipse.swt.events.ModifyListener)355 Listener (org.eclipse.swt.widgets.Listener)354 Event (org.eclipse.swt.widgets.Event)352 ModifyEvent (org.eclipse.swt.events.ModifyEvent)350 Display (org.eclipse.swt.widgets.Display)343 ShellEvent (org.eclipse.swt.events.ShellEvent)335 ShellAdapter (org.eclipse.swt.events.ShellAdapter)330 TextVar (org.pentaho.di.ui.core.widget.TextVar)220 ColumnInfo (org.pentaho.di.ui.core.widget.ColumnInfo)200 TableView (org.pentaho.di.ui.core.widget.TableView)198