/** * Maximize the child control of sashform passed. * * @param control - the child control of sashform to maximize or restore */ private void maximizeControl(Control control) { if (sashForm.getMaximizedControl() == control) { sashForm.setMaximizedControl(null); } else { sashForm.setMaximizedControl(control); } }
private void createLiteratureWidgets(Composite parent) { // criando imagens String PLUGIN_ID = "br.ufpe.cin.reviewer.ui.rcp"; Bundle bundle = Platform.getBundle(PLUGIN_ID); Image addIcon = ImageDescriptor.createFromURL( FileLocator.find(bundle, new Path("images/Add-Green-Button-icon.png"), null)) .createImage(); Image minusIcon = ImageDescriptor.createFromURL( FileLocator.find(bundle, new Path("images/Minus-Green-Button-icon.png"), null)) .createImage(); Image AutomaticIcon = ImageDescriptor.createFromURL( FileLocator.find(bundle, new Path("images/A-Green-Button-icon.png"), null)) .createImage(); Image ManualIcon = ImageDescriptor.createFromURL( FileLocator.find(bundle, new Path("images/M-Green-Button-icon.png"), null)) .createImage(); Image DeleteIcon = ImageDescriptor.createFromURL( FileLocator.find(bundle, new Path("images/D-Green-Button-icon.png"), null)) .createImage(); sash = new SashForm(form.getBody(), SWT.HORIZONTAL); sash.setLayout(new GridLayout(4, false)); GridData sashLayout = new GridData(GridData.FILL_BOTH); sashLayout.grabExcessHorizontalSpace = true; sashLayout.grabExcessVerticalSpace = true; sash.setLayoutData(sashLayout); sash.getMaximizedControl(); // Section for List of reviews sectionList = toolkit.createSection(sash, Section.SHORT_TITLE_BAR); sectionList.setText("REVIEWS"); sectionList.setLayout(new GridLayout(1, false)); GridData sectionListLayout = new GridData(GridData.FILL_VERTICAL); sectionListLayout.horizontalSpan = 1; sectionList.setLayoutData(sectionListLayout); toolbarList = new ToolBar(sectionList, SWT.NONE); ToolItem itemAddReview = new ToolItem(toolbarList, SWT.BUTTON1); itemAddReview.setImage(addIcon); ToolItem itemDeleteReview = new ToolItem(toolbarList, SWT.BUTTON1); itemDeleteReview.setImage(minusIcon); sectionList.setTextClient(toolbarList); listComposite = toolkit.createComposite(sectionList, SWT.BORDER); listComposite.setLayout(new GridLayout(2, false)); listComposite.setLayoutData(new GridData()); list = new List(listComposite, SWT.V_SCROLL); GridData listLayoutData = new GridData(GridData.FILL_BOTH); listLayoutData.horizontalSpan = 1; list.setLayoutData(listLayoutData); list.addSelectionListener(new LiteratureReviewsListHandler()); refreshLiteratureView(); itemAddReview.addSelectionListener(new LiteratureReviewAddReviewHandler()); itemDeleteReview.addSelectionListener(new LiteratureReviewRemoveReviewHandler()); // Section for review information sectionInfo = toolkit.createSection(sash, Section.SHORT_TITLE_BAR); sectionInfo.setText("REVIEW INFO"); sectionInfo.setLayout(new GridLayout(1, false)); sectionInfo.setLayoutData(new GridData(GridData.FILL_BOTH)); reviewInfoComposite = toolkit.createComposite(sectionInfo, SWT.BORDER); GridData reviewCompositeData = new GridData(GridData.FILL_BOTH); reviewCompositeData.horizontalSpan = 1; reviewInfoComposite.setLayoutData(reviewCompositeData); reviewInfoComposite.setLayout(new GridLayout(3, false)); reviewInfoComposite.setVisible(true); // Review Title titleLabel = toolkit.createLabel(reviewInfoComposite, "TITLE: "); titleLabel.setFont( new Font(UIConstants.APP_DISPLAY, UIConstants.SYSTEM_FONT_NAME, 10, SWT.BOLD)); titleLabel.setLayoutData(new GridData()); // Review Title titleInfoLabel = toolkit.createLabel(reviewInfoComposite, "Pesquisa 1"); titleInfoLabel.setFont( new Font(UIConstants.APP_DISPLAY, UIConstants.SYSTEM_FONT_NAME, 10, SWT.NONE)); GridData titleInfoLabelData = new GridData(GridData.FILL_HORIZONTAL); titleInfoLabelData.horizontalSpan = 2; titleInfoLabel.setLayoutData(titleInfoLabelData); // Criteria List sectionCriteria = toolkit.createSection(reviewInfoComposite, Section.SHORT_TITLE_BAR); sectionCriteria.setText("CRITERIONS"); sectionCriteria.setLayout(new GridLayout(2, false)); GridData sectionCriteriaLayout = new GridData(GridData.FILL_HORIZONTAL); sectionCriteriaLayout.horizontalSpan = 3; sectionCriteria.setLayoutData(sectionCriteriaLayout); toolbarCriteria = new ToolBar(sectionCriteria, SWT.NONE); ToolItem itemAddCriteria = new ToolItem(toolbarCriteria, SWT.BUTTON1); itemAddCriteria.setImage(addIcon); ToolItem itemDeleteCriteria = new ToolItem(toolbarCriteria, SWT.BUTTON1); itemDeleteCriteria.setImage(minusIcon); sectionCriteria.setTextClient(toolbarCriteria); criteriaListComposite = toolkit.createComposite(sectionCriteria, SWT.BORDER); criteriaListComposite.setLayout(new GridLayout(1, false)); criteriaListComposite.setLayoutData(new GridData()); criteriaList = new List(criteriaListComposite, SWT.V_SCROLL); GridData criterialistLayout = new GridData(GridData.FILL_BOTH); criterialistLayout.horizontalSpan = 1; criteriaList.setLayoutData(criterialistLayout); criteriaList.addSelectionListener(new CriteriaListHandler()); refreshCriteriaList(); itemAddCriteria.addSelectionListener(new LiteratureReviewAddCriteriaHandler()); itemDeleteCriteria.addSelectionListener(new LiteratureReviewRemoveCriteriaHandler()); // Studies section sectionStudies = toolkit.createSection(reviewInfoComposite, Section.SHORT_TITLE_BAR); sectionStudies.setText("STUDIES"); sectionStudies.setLayout(new GridLayout(2, false)); GridData sectionStudiesLayout = new GridData(GridData.FILL_BOTH); sectionStudiesLayout.horizontalSpan = 3; sectionStudies.setLayoutData(sectionStudiesLayout); toolbarStudies = new ToolBar(sectionStudies, SWT.NONE); final ToolItem itemAutomatic = new ToolItem(toolbarStudies, SWT.DROP_DOWN); itemAutomatic.setImage(AutomaticIcon); itemAutomatic.addSelectionListener( new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { // super.widgetSelected(e); Menu menu = new Menu(form.getShell(), SWT.POP_UP); MenuItem item1 = new MenuItem(menu, SWT.PUSH); item1.setText("New search"); item1.addSelectionListener( new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { IPerspectiveRegistry perspectiveRegistry = PlatformUI.getWorkbench().getPerspectiveRegistry(); IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); activePage.setPerspective( perspectiveRegistry.findPerspectiveWithId(SearchPerspective.ID)); } @Override public void widgetDefaultSelected(SelectionEvent e) { // TODO Auto-generated method stub } }); MenuItem item2 = new MenuItem(menu, SWT.PUSH); item2.setText("import BibText"); Point loc = itemAutomatic.getParent().getLocation(); Rectangle rect = itemAutomatic.getBounds(); Point mLoc = new Point(loc.x - 1, loc.y + rect.height); menu.setLocation( form.getShell() .getDisplay() .map(itemAutomatic.getParent().getParent(), null, mLoc)); menu.setVisible(true); } @Override public void widgetDefaultSelected(SelectionEvent e) { // TODO Auto-generated method stub } }); final ToolItem itemManual = new ToolItem(toolbarStudies, SWT.DROP_DOWN); itemManual.setImage(ManualIcon); itemManual.addSelectionListener( new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { // super.widgetSelected(e); Menu menu = new Menu(form.getShell(), SWT.POP_UP); MenuItem item1 = new MenuItem(menu, SWT.PUSH); item1.setText("Add Study"); item1.addSelectionListener( new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { MessageBox manualDialog = new MessageBox(form.getShell(), SWT.ICON_ERROR); manualDialog.setText("Reviewer"); manualDialog.setMessage("Teste"); int returnCode = manualDialog.open(); } @Override public void widgetDefaultSelected(SelectionEvent e) { // TODO Auto-generated method stub } }); MenuItem item2 = new MenuItem(menu, SWT.PUSH); item2.setText("Import BibText"); Point loc = itemManual.getParent().getLocation(); Rectangle rect = itemManual.getBounds(); Point mLoc = new Point(loc.x + 38, loc.y + rect.height); menu.setLocation( form.getShell().getDisplay().map(itemManual.getParent().getParent(), null, mLoc)); menu.setVisible(true); } @Override public void widgetDefaultSelected(SelectionEvent e) { // TODO Auto-generated method stub } }); final ToolItem itemDeleteStudies = new ToolItem(toolbarStudies, SWT.DROP_DOWN); itemDeleteStudies.setImage(DeleteIcon); itemDeleteStudies.addSelectionListener( new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { // super.widgetSelected(e); Menu menu = new Menu(form.getShell(), SWT.POP_UP); MenuItem item1 = new MenuItem(menu, SWT.PUSH); item1.setText("Remove by title"); MenuItem item2 = new MenuItem(menu, SWT.PUSH); item2.setText("Remove by abstract"); Point loc = itemDeleteStudies.getParent().getLocation(); Rectangle rect = itemDeleteStudies.getBounds(); Point mLoc = new Point(loc.x + 76, loc.y + rect.height); menu.setLocation( form.getShell() .getDisplay() .map(itemDeleteStudies.getParent().getParent(), null, mLoc)); menu.setVisible(true); } @Override public void widgetDefaultSelected(SelectionEvent e) { // TODO Auto-generated method stub } }); sectionStudies.setTextClient(toolbarStudies); studiesComposite = toolkit.createComposite(sectionStudies, SWT.BORDER); studiesComposite.setLayout(new GridLayout(1, false)); studiesComposite.setLayoutData(new GridData()); // Manual Studies section sectionManual = toolkit.createSection(studiesComposite, Section.SHORT_TITLE_BAR); sectionManual.setText("MANUAL STUDIES"); sectionManual.setLayout(new GridLayout(2, false)); GridData sectionManualLayout = new GridData(GridData.FILL_BOTH); sectionManualLayout.horizontalSpan = 2; sectionManual.setLayoutData(sectionManualLayout); toolbarManual = new ToolBar(sectionManual, SWT.NONE); ToolItem itemDeleteManual = new ToolItem(toolbarManual, SWT.BUTTON1); itemDeleteManual.setImage(minusIcon); sectionManual.setTextClient(toolbarManual); manualComposite = toolkit.createComposite(sectionManual, SWT.BORDER); manualComposite.setLayout(new GridLayout(1, false)); manualComposite.setLayoutData(new GridData()); // Info Table infoTable = toolkit.createTable(manualComposite, SWT.BORDER | SWT.FULL_SELECTION); infoTable.setLinesVisible(true); infoTable.setHeaderVisible(true); GridData infoTableLayoutData = new GridData(GridData.FILL_BOTH); infoTable.setLayoutData(infoTableLayoutData); // insert columns and set their names String[] titles = {"info 1", "info 2", "info 3", "info 4"}; for (int i = 0; i < titles.length; i++) { TableColumn column = new TableColumn(infoTable, SWT.NONE); column.setText(titles[i]); } for (int i = 0; i < titles.length; i++) { infoTable.getColumn(i).pack(); } // Automatic Studies section sectionAutomatic = toolkit.createSection(studiesComposite, Section.SHORT_TITLE_BAR); sectionAutomatic.setText("AUTOMATIC STUDIES"); sectionAutomatic.setLayout(new GridLayout(2, false)); GridData sectionAutomaticLayout = new GridData(GridData.FILL_BOTH); sectionAutomaticLayout.horizontalSpan = 2; sectionAutomatic.setLayoutData(sectionAutomaticLayout); toolbarAutomatic = new ToolBar(sectionAutomatic, SWT.NONE); ToolItem itemDeleteAutomatic = new ToolItem(toolbarAutomatic, SWT.BUTTON1); itemDeleteAutomatic.setImage(minusIcon); sectionAutomatic.setTextClient(toolbarAutomatic); automaticComposite = toolkit.createComposite(sectionAutomatic, SWT.BORDER); automaticComposite.setLayout(new GridLayout(2, false)); automaticComposite.setLayoutData(new GridData()); // Query String Label QueryStringLabel = toolkit.createLabel(automaticComposite, "QUERY STRING: "); QueryStringLabel.setFont( new Font(UIConstants.APP_DISPLAY, UIConstants.SYSTEM_FONT_NAME, 10, SWT.BOLD)); QueryStringLabel.setLayoutData(new GridData()); // Query String Label QueryLabel = toolkit.createLabel(automaticComposite, ""); QueryLabel.setFont( new Font(UIConstants.APP_DISPLAY, UIConstants.SYSTEM_FONT_NAME, 10, SWT.NONE)); QueryLabel.setLayoutData(new GridData()); // Source Label SourceLabel = toolkit.createLabel(automaticComposite, "SOURCE"); SourceLabel.setFont( new Font(UIConstants.APP_DISPLAY, UIConstants.SYSTEM_FONT_NAME, 10, SWT.BOLD)); GridData sourceLabelData = new GridData(); sourceLabelData.horizontalSpan = 2; SourceLabel.setLayoutData(sourceLabelData); // Source Table sourceTable = toolkit.createTable(automaticComposite, SWT.BORDER | SWT.FULL_SELECTION); sourceTable.setLinesVisible(true); sourceTable.setHeaderVisible(true); GridData sourceTableLayoutData = new GridData(GridData.FILL_BOTH); sourceTableLayoutData.horizontalSpan = 2; sourceTable.setLayoutData(sourceTableLayoutData); // insert columns and set their names String[] titles2 = {"Source", "Total Founded", "Total Fetched"}; for (int i = 0; i < titles2.length; i++) { TableColumn column = new TableColumn(sourceTable, SWT.NONE); column.setText(titles2[i]); } for (int i = 0; i < titles2.length; i++) { sourceTable.getColumn(i).pack(); } buttonInfoComposite = toolkit.createComposite(reviewInfoComposite); buttonInfoComposite.setLayout(new GridLayout(2, false)); GridData buttonInfoData = new GridData(GridData.FILL_HORIZONTAL); buttonInfoData.horizontalSpan = 3; buttonInfoData.grabExcessHorizontalSpace = true; buttonInfoComposite.setLayoutData(buttonInfoData); exportButton = toolkit.createButton(buttonInfoComposite, "Export review", SWT.PUSH); GridData exportButtonLayoutData = new GridData(GridData.FILL_HORIZONTAL); exportButtonLayoutData.horizontalAlignment = SWT.RIGHT; // exportButtonLayoutData.grabExcessHorizontalSpace = true; exportButtonLayoutData.horizontalSpan = 1; exportButton.setLayoutData(exportButtonLayoutData); evaluateButton = toolkit.createButton(buttonInfoComposite, "evaluate studies", SWT.PUSH); GridData evaluateButtonLayoutData = new GridData(); evaluateButtonLayoutData.horizontalAlignment = SWT.RIGHT; // evaluateButtonLayoutData.grabExcessHorizontalSpace = true; evaluateButtonLayoutData.horizontalSpan = 1; evaluateButton.setLayoutData(evaluateButtonLayoutData); evaluateButton.addSelectionListener(new LiteratureReviewPhasesButtonHandler()); sash.setWeights(new int[] {1, 3}); sectionList.setClient(listComposite); sectionInfo.setClient(reviewInfoComposite); sectionCriteria.setClient(criteriaListComposite); sectionStudies.setClient(studiesComposite); sectionManual.setClient(manualComposite); sectionAutomatic.setClient(automaticComposite); }