public void clickVoteOnIdea() { if (display.isDisposed()) return; if ((clientWhiteboard.getSelectionControl().getSelectedIdeas().size() + clientWhiteboard.getSelectionControl().getSelectedIdeas().size()) == 0) return; GuiCreateComment guicomment = new GuiCreateComment(getPlayerId(), display, clientCore.getGame(), clientCore); guicomment.init( clientWhiteboard.getSelectionControl().getSelectedIdeas(), clientWhiteboard.getSelectionControl().getSelectedComments()); guicomment.run(); if (guicomment.getResultName() == null) return; // user cancelled /* try { clientCore.getGame().addIdea( getPlayerId(), guiCreateIdea.getResultName(), guiCreateIdea.getResultItemIds(), guiCreateIdea.getResultParentIds() ); } catch (Exception e) { displayError("error while creating the idea", e); }*/ }
public void clickCreateIdea() { if (display.isDisposed()) return; GuiCreateIdea guiCreateIdea = new GuiCreateIdea(getPlayerId(), display, clientCore.getGame()); guiCreateIdea.init( clientWhiteboard.getSelectionControl().getSelectedIdeas(), clientWhiteboard.getSelectionControl().getSelectedItems()); guiCreateIdea.run(); if (guiCreateIdea.getResultName() == null) return; // user probably cancelled try { clientCore .getGame() .addIdea( getPlayerId(), guiCreateIdea.getResultName(), guiCreateIdea.getResultDesc(), guiCreateIdea.getResultItemIds(), guiCreateIdea.getResultParentIds()); } catch (Exception e) { displayError("error while creating the idea", e); } }
private void clickEditVisuParams() { if (display.isDisposed()) return; GUIParameters guiParams = new GUIParameters(display, "Visu Parameters", GUIParametersMode.STANDALONE); guiParams.init(clientWhiteboard.getParameters()); guiParams.refreshDirect(); guiParams.openDirect(); }
/** * Connects to this game. * * @param gameBindName * @throws MalformedURLException * @throws RemoteException * @throws NotBoundException * @throws UnknownHostException */ public void connectToGame(String gameBindName) throws MalformedURLException, RemoteException, NotBoundException, UnknownHostException { try { clientCore.connectToGame(gameBindName); clientWhiteboard.setGame(clientCore.getGame()); clientCore.getGame().addListener(this); setClientMode(GuiClientMode.MONITOR); this.gameBindName = gameBindName; } catch (RuntimeException e) { // update info relative to the game. setClientMode(GuiClientMode.DISCONNECTED); this.gameBindName = null; throw e; } }
private void updateMenuStates() { itemConnectAndJoin.setEnabled(modeClient == GuiClientMode.DISCONNECTED); itemCreateJoinAndPlay.setEnabled( modeClient == GuiClientMode.DISCONNECTED && modeServer == GuiServerMode.NO_SERVER); itemCreateJoin.setEnabled( modeClient == GuiClientMode.DISCONNECTED && modeServer == GuiServerMode.NO_SERVER); itemObserve.setEnabled(modeClient == GuiClientMode.DISCONNECTED); itemJoin.setEnabled(modeClient == GuiClientMode.MONITOR); itemDisconnect.setEnabled(modeClient != GuiClientMode.DISCONNECTED); itemCreateGame.setEnabled(modeClient == GuiClientMode.DISCONNECTED); itemCreateServerLocal.setEnabled(modeServer == GuiServerMode.NO_SERVER); itemCreateServer.setEnabled(modeServer == GuiServerMode.NO_SERVER); itemShutdownServer.setEnabled(modeServer != GuiServerMode.NO_SERVER); itemCreateGame.setEnabled(modeServer != GuiServerMode.NO_SERVER); clientWhiteboard.setActionsEnabled(modeClient == GuiClientMode.PLAYING); }
public void init() { display = new Display(); shell = new Shell(display, SWT.SHELL_TRIM); shell.setText(TXT_WINDOW_TITLE); // shell.setLayout(new GridLayout(2, false)); shell.setLayout(new GridLayout(1, false)); initMenus(); // left pane: whiteboard { Composite compositeWhiteboard = new Composite(shell, SWT.EMBEDDED | SWT.NO_BACKGROUND | SWT.BORDER); GridData gdWhiteboard = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL); compositeWhiteboard.setLayoutData(gdWhiteboard); clientWhiteboard = new ClientWhiteboardSWT(compositeWhiteboard); clientWhiteboard.init(this); clientWhiteboard.setLayoutActive(true); } // right pane: buttons + comments { /* Composite compositeRight = new Composite(shell, SWT.NONE); GridData gdRight = new GridData(GridData.FILL_VERTICAL); compositeRight.setLayoutData(gdRight); compositeRight.setLayout(new GridLayout()); */ Composite compositeBottom = new Composite(shell, SWT.NONE); GridData gdBottom = new GridData(GridData.FILL_HORIZONTAL); compositeBottom.setLayoutData(gdBottom); compositeBottom.setLayout(new GridLayout(3, false)); // scores { Composite compositeScores = new Composite(compositeBottom, SWT.NONE); compositeScores.setLayout(new GridLayout(1, false)); compositeScores.setLayoutData( new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING)); scores = new Label[TypeScore.values().length]; scoreslab = new Label[TypeScore.values().length]; rg = new Label[TypeScore.values().length]; rglab = new Label[TypeScore.values().length]; scoreevo = new Label[TypeScore.values().length]; rgevo = new Label[TypeScore.values().length]; int i = 0; scvalprec = new HashMap<Integer, Double>(TypeScore.values().length, 1.0f); scrgprec = new HashMap<Integer, Double>(TypeScore.values().length, 1.0f); // AD TXT_TOOLTIP_HIGH_SCORE=new ArrayList(TypeScore.values().length); /* TXT_TOOLTIP_HIGH_SCORE = new ArrayList<String>(TypeScore.values().length); // */ for (TypeScore sc : TypeScore.values()) { scvalprec.put(i, (double) 0); scrgprec.put(i, (double) 1); // compositeSc.setLayout(new RowLayout(SWT.HORIZONTAL)); Composite compositeSc = new Composite(compositeScores, SWT.NONE); GridLayout layoutName = new GridLayout(6, false); GridData gdSc = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING); compositeSc.setBackground(LOOK_COLOR_BACKGROUND_SUBSPACES); compositeSc.setLayout(layoutName); compositeSc.setLayoutData(gdSc); scoreslab[i] = new Label(compositeSc, SWT.READ_ONLY); scoreslab[i].setText(sc.nom + ":"); scoreslab[i].setBackground(LOOK_COLOR_BACKGROUND_SUBSPACES); scoreslab[i].setLayoutData( new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_END)); scoreslab[i].setToolTipText(sc.tooltip); scores[i] = new Label(compositeSc, SWT.READ_ONLY); scores[i].setText(" 0000"); scores[i].setBackground(LOOK_COLOR_BACKGROUND_SUBSPACES); scores[i].setLayoutData( new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_END)); TXT_TOOLTIP_HIGH_SCORE.add(i, "High Scores"); scores[i].setToolTipText(TXT_TOOLTIP_HIGH_SCORE.get(i)); scoreevo[i] = new Label(compositeSc, SWT.READ_ONLY); scoreevo[i].setText(" (==)"); scoreevo[i].setBackground(LOOK_COLOR_BACKGROUND_SUBSPACES); scoreevo[i].setLayoutData( new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_END)); rglab[i] = new Label(compositeSc, SWT.READ_ONLY); rglab[i].setText(" Rg:"); rglab[i].setBackground(LOOK_COLOR_BACKGROUND_SUBSPACES); rglab[i].setLayoutData( new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_END)); rg[i] = new Label(compositeSc, SWT.READ_ONLY); rg[i].setText(" 00"); rg[i].setBackground(LOOK_COLOR_BACKGROUND_SUBSPACES); rg[i].setLayoutData( new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_END)); rgevo[i] = new Label(compositeSc, SWT.READ_ONLY); rgevo[i].setText(" (==)"); rgevo[i].setBackground(LOOK_COLOR_BACKGROUND_SUBSPACES); rgevo[i].setLayoutData( new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_END)); i++; } { // init the timer for refreshing this display.timerExec( PERIOD_REFRESH_SCORES, new Runnable() { public void run() { majScores(); display.timerExec(PERIOD_REFRESH_SCORES, this); } }); } } // comments { Composite compositeComments = new Composite(compositeBottom, SWT.NONE); GridData gdComments = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL); compositeComments.setLayoutData(gdComments); compositeComments.setLayout(new GridLayout()); // it is initialy empty, as no idea is selected ideaCommentTree = new Tree(compositeComments, SWT.VIRTUAL | SWT.BORDER); ideaCommentTree.setLayoutData( new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL | GridData.GRAB_HORIZONTAL)); // this Rennable is used to refresh comments displayed in the bottom part. // what ? this should be somewhere else ? hum... that's called anarchy. Or collaborative // work ? ideaCommentTreeFillerRunnable = new Runnable() { @Override public void run() { selectedIdeas = clientWhiteboard.getSelectionControl().getSelectedIdeas(); if (!selectedIdeas.isEmpty()) { ideaCommentTree.removeAll(); for (IIdea i : selectedIdeas) { try { clientCore.displayIdeaComments(i.getUniqueId(), ideaCommentTreeFiller); } catch (RemoteException e) { displayError("an anormal remote exception happened.", e); } } } } }; // make the tree resets its data when a new idea is selected clientWhiteboard .getSelectionControl() .addListener( new ISelectionListener() { @Override public void notifySelectionChanged() { display.asyncExec(ideaCommentTreeFillerRunnable); } }); } // buttons { Composite compositeButtons = new Composite(compositeBottom, SWT.NONE); GridData gdButtons = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING); compositeButtons.setLayoutData(gdButtons); compositeButtons.setLayout(new RowLayout(SWT.VERTICAL)); buttonAddIdea = new Button(compositeButtons, SWT.PUSH); buttonAddIdea.setText("Ajouter une idée"); buttonAddIdea.addSelectionListener( new SelectionListener() { @Override public void widgetSelected(SelectionEvent arg0) { clickCreateIdea(); } @Override public void widgetDefaultSelected(SelectionEvent arg0) { clickCreateIdea(); } }); buttonComment = new Button(compositeButtons, SWT.PUSH); buttonComment.setText("Commenter / Miser"); buttonComment.addSelectionListener( new SelectionListener() { @Override public void widgetSelected(SelectionEvent arg0) { clickVoteOnIdea(); } @Override public void widgetDefaultSelected(SelectionEvent arg0) { clickVoteOnIdea(); } }); buttonAddItem = new Button(compositeButtons, SWT.PUSH); buttonAddItem.setText("Ajouter un item"); buttonAddItem.addSelectionListener( new SelectionListener() { @Override public void widgetSelected(SelectionEvent arg0) { clickCreateItem(); } @Override public void widgetDefaultSelected(SelectionEvent arg0) { clickCreateItem(); } }); } } clientCore = new DelegatingClientCore(clientWhiteboard); updateStates(); updateShellTitle(); }